Live data from Hacker News

Cloudflare Pages: Best server tech since CGI-bin?

taras.glek.net

161–170 of 226 posts

Re: Cloudflare Pages: Best server tech since CGI-bin?

#161
post #88

Earlier quoted context omitted.

> Yes, it's great because static/static+some dynamic bits fits a lot of use cases and it's quite simple to deploy, manage and maintain. Do you have some examples? I always get excited by this serverless stuff, but often the use-cases are quite limited if you think about it, or maybe I’m thinking wrong, especially if you take vendor lock into consideration.

A simple usecase I had was submitting a contact us form from a static marketing site and being able to route it somewhere .

No post body was provided.

Re: Cloudflare Pages: Best server tech since CGI-bin?

#162
post #30

I am waiting for the time where we can host WordPress freely with static hosting and workers for admin ui/dynamic content. Otherwise static websites are only for devs.

I've successfully run WordPress with the simply-static plugin, and a script to send to static hosting. WP run on an arm64 instance that was only started when editing was needed. Besides WP, there are static CMSes that fit a modern workflow perfectly.

> I've successfully run WordPress with the simply-static plugin, and a script to send to static hosting.

Interesting, simply-static never worked for me, only wp2static did and it had a lot of bugs.

> WP run on an arm64 instance that was only started when editing was needed.

How do you do this?, are you doing some kind of webserver container run trigger? Or running it on a managed platform?

> Besides WP, there are static CMSes that fit a modern workflow perfectly.

Yeah but they aren't so customizable and flexible like WordPress, the goal is to be able to create a whole static site without needing to write anything manually.

Re: Cloudflare Pages: Best server tech since CGI-bin?

#163

I am waiting for the time where we can host WordPress freely with static hosting and workers for admin ui/dynamic content. Otherwise static websites are only for devs.

They have a product for that https://www.cloudflare.com/pg-lp/speed-up-wordpress-with-clo... It caches all pages on Cloudflare and only bypasses Cache on Cookies such as `wp-. |wordpress. |comment_. |wordpress_logged_. ` which is used by /wp-admin/ are and when someone posts a comment. This turns your WP into static without doing anything special. Or you can write a custom cache rule for cookies using "Page Rules" or…

This would require you to host WordPress somewhere.

If you can host it on workers for example, you can get an entirety free, managed website just with one click(obviously someone would do a template to enable you to setup wp on cf pages if that was possible).

Re: Cloudflare Pages: Best server tech since CGI-bin?

#164
I get that the engine is open source, but CGI-bin is a standard interface while Cloudflare Pages is a service.

In practice, no one is running workerd at their VMs, so it seems weird for me to compare the two.

Cloudflare Pages is better than [insert your favorite hosting service] would make more sense. Still, very cool tech.

Re: Cloudflare Pages: Best server tech since CGI-bin?

#165
post #61

I feel like there's a large class of tools in this space now (Vercel, Netlify) that do all of this and more, and this post is less about Cloudflare Pages and more about the (really good) state of static hosting these days? One thing that stuck out was the comment about "Twitter cards", since Vercel/Next now has this built in: https://twitter.com/vercel/status/1579561293069316096

No it’s pointing out the server side scripting part which was new to me. do analogs exist in those other hosting options? This seems like a really nice facility - closest analog client side wise is a service worker or something that adjusts fetch.

Yes, many of the other services can do server-side rendering (SSR), deferred static generation (DSG), and/or incremental static rendering (ISR).

Re: Cloudflare Pages: Best server tech since CGI-bin?

#166
post #64
post #26

Earlier quoted context omitted.

Yes, it's great because static/static+some dynamic bits fits a lot of use cases and it's quite simple to deploy, manage and maintain. It's nothing that new though, Firebase (part of GCP) and Netlify have had that for years. CloudFlare just have the right combination of marketing, reputation, pricing and tech to make headlines with it again.

I have never seen an example where you land a JS file in a static website in git and it just runs as part of server side middleware. Seems legit novel but would like to know other examples.

It's similar to what I was doing 10 to 5 years ago but in Perl.

Drop a file into a directory which is all or mostly static Markdown, HTML or CSS, but those files can contain markup to call other modules, as well as code files.

The existence of a file is enough for its index code to be run (if it has any) and any URL-set and page components it makes available are available to other pages to be used, or served as they are. A single file can offer many URLs, usually anchored at the name of the file but not necessarily. The reason it can affect URLs outside the name of the file itslf is that it's efficient to index all files in a directory tree, even on every HTTP request, if that's done by file change detection and the results are efficiently cached.

Some of those files act as filtering middleware, processing the input and output of some or all URLs and passing along what they don't change.

Updating static Markdown, HTML and CSS, dynamic content, code, and JSON data, are done by 'git push' or 'rsync', or just by editing files in place if you prefer. The server automatically detects file changes and keeps track of all code, file and data dependencies when individual things are used to calculate a response. The full dependency structure for each response calculation is recorded with each cached response.

Cached responses include both full HTTP responses, and components and data available for use in the manner of a subrequest. If a previously cached response depends on a file that has since changed, or been removed, or even a file that was previously absent but now present, or another cache condition such as a JSON or SQLite file change, or logged in user etc, the cached response is invalid and must be regenerated. Regeneration is a combination of on-demand and ahead-of-time, to be able to respond quickly with the speed of a static site for small finite page collections, while behaving correctly with large or infinite collections. Some code updates trigger a process restart because some code can't be safely unloaded or replaced; some code is fine updated, though, and this entire process is well automated. In practice, pleasant and fast to use: edit a file and see the result immediately on reload, with no compile/build step or extra actions.

The dependency structure partly reaches the browser, so that requests to cached responses can be served more efficiently, sometimes even zero latency. In some circumtances, changes in files cause events that ripple through to the browser causing real-time updates to components in-page without a refresh. The result of those is a little like Meteor or LiveView, except almost everything is made from static page files in Markdown or HTML, code files, and JSON data files, and the set of available pages (and "table of contents" pages) are built by indexing those files.

In practice it's mostly writing Markdown, and this is great for emphasis on content first. Or Markdown templates: content that varies a little according to data. But with extensions to be able to drop in useful rendered components (graphs, generated images, templated CSS, transclusions for headers/footers, etc) and dynamic components (live updating when the underlying data files are edited).

It even serves PDFs and thumbnails of those as in-page components, where the PDF content is HTML rendered by running Chrome on the fly from within an in-page component to generate the PDF or image, with Chrome told to fetch a subrequest which serves it the contents of that very same component. This makes for some pretty lists of downloadable PDFs, all generated from JSON data. This probably sounds complicated, but it was actually a fairly simple single file of code, dropped into a directory to make the component available by name inside the other Markdown quasi-static files.

One small VM served a few thousand requests per second last time I checked. Not as fast as a Rust server, but good enough for my uses. It made heavy use of Perl coroutines to serve and cache concurrently, and NginX to make routing and static-serve decisions. Perl coroutines are not commonly used (for ideological reasons I think), but they work very well.

I don't use the sytem any more, but it was the nicest I've used.

Re: Cloudflare Pages: Best server tech since CGI-bin?

#167
post #9

The rest of the industry haven't even started figuring out what Cloudflare Pages Functions + Durable Objects can do. Workers can also send emails for free, and soon you will be able to process them as well with Email Workers. Cloudflare also doesn't charge you for egress either.

> The rest of the industry haven't even started figuring out what Cloudflare Pages Functions + Durable Objects can do

I was very excited when both of these technologies were first announced (years ago).

I tried them, immediately, then (during the initial beta). They were clunky, half-baked, and don't even get me started on the DX of developing against them. Literally missing from cloudflare's own CLI - the official docs described how to manually deploy via CURLing endpoints. It felt like manually FTPing files onto a server, like in the 90s.

Ok fine, this is an early beta, let's let this bake longer.

So a few months ago, I started a new greenfield project and once again decided to give Functions + Durable Objects a shot... and was astounded to find the exact same half-baked experience, where different "beta" versions of the CLI had to be installed in order to support the different endpoints, and these were in fact mutually-exclusive.

Cloudflare has some cool ideas, but they seem to like rolling out 70% of a cool idea and then moving into the next shiny thing without ever making the first thing actually polished and reliable. After wasting many hours with Cloudflare's DX, I decided to never waste more time with them as a development platform (vs an optimization layer / CDN / etc).

Re: Cloudflare Pages: Best server tech since CGI-bin?

#168

Side note: As someone who wanted a high level overview of Durable Objects, the Cloudflare announcement page 404s https://blog.cloudflare.com/introducing-workers-durable-obje...

This sounds magical: > Durable Objects make this easy. Not only do they make it easy to assign a coordination point, but Cloudflare will automatically create the coordinator close to the users using it and migrate it as needed, minimizing latency.

It sounds magical. I would recommend trying it first... the experience of trying to actually build anything with it is quite un-magical. The documentation, CLI, workflow, and pricing (for sockets especially) all fall quite short.

Re: Cloudflare Pages: Best server tech since CGI-bin?

#170
post #169

I have been working on servers whether professionally as a software engineer or as a pre-teen making a The Simpsons fan website for a couple decades now. I have never once used that `cgi-bin`, never opened it, and still have no idea wtf it is.

Back when we used to write CGI using Perl or straight up C.
Post reply on HN