[HN Gopher] Cloudflare Pages: Best server tech since CGI-bin? ___________________________________________________________________ Cloudflare Pages: Best server tech since CGI-bin? Author : mehal Score : 242 points Date : 2022-10-23 16:03 UTC (6 hours ago) (HTM) web link (taras.glek.net) (TXT) w3m dump (taras.glek.net) | jasonhansel wrote: | Why not just make it CGI (or FastCGI) compatible so you can test | it locally or run it in other environments? At least for things | that are actually generating responses rather than acting as | middleware. | | Oh, right, vendor lock-in. | mfer wrote: | It's different that than vendor lock-in. | | For example you have security. CGI with multitenants is hard if | not impossible. At least for the tenants that will want to use | this. | | Then there is scaling, resource consumption, and predictability | (for planning). | kentonv wrote: | The engine is open source: | https://github.com/cloudflare/workerd | | We did not create our own engine to create "lock-in". On the | contrary, it would be a huge win for us if we could simply run | FastCGI or Node or whatever applications unmodified. We'd be | able to onboard a lot more customers more quickly that way! Our | product is our physical network (with hundreds of locations | around the world), not our specific development environment. | | But none of that tech scales well enough that we could run | every app in every one of our locations at an affordable price. | Meeting that goal required new tech. The best we could do is | base it on open standard APIs (browser APIs, mostly), so a lot | of code designed for browsers ports over nicely. | | (I'm the lead engineer for Workers. These were my design | choices, originally.) | spiffytech wrote: | Are there guides for application architecture with Workers? | | I'm interested in Durable Objects but I don't know how to | work within the 50-subrequest limit on the Free or Bundled | plans. | | It sounds like I can only read from 50 Durable Objects or KV | queries in a single request. If my usage pattern is e.g., | sharing docs with many users, how would I let more than 50 | users access a doc? | | Whether I consider fanning out on writes or fanning in on | reads I'd need more than 50 subrequests. How should I | approach this? | kentonv wrote: | Hmm, I think there are several different reasons why the | subrequest limit actually doesn't apply to your scenario. | | First, Durable Objects and Workers KV requests do not count | against the 50-subrequest limit. It's HTTP requests to | external servers that count. | | Second, with the Unbound billing model, the limit is now | 1000. The old "Bundled" billing model is really intended | for "configure your CDN" use cases where you're mostly just | rewriting a request or response and proxying to origin. For | whole applications you should use Unbound. (Note that with | Durable Objects, the objects themselves always use the | Unbound pricing model.) | | Third, to address your specific scenario: | | > If my usage pattern is e.g., sharing docs with many | users, how would I let more than 50 users access a doc? | | If you mean you have 50+ users connected via WebSockets and | you need to send a message to each one -- these messages | (on already-open WebSockets) do not count against the | subrequest limit. Only starting a whole new HTTP request or | new WebSocket would count. | | And for "fan in", these would be incoming requests from | client, but the subrequest limit applies to outgoing | request. There's no limit on number of incoming requests. | spiffytech wrote: | > First, Durable Objects and Workers KV requests do not | count against the 50-subrequest limit. It's HTTP requests | to external servers that count. | | Ahhh, somehow I got the idea that requests from a Worker | to Durable Objects and KV counted against subrequests. | This changes things! | | > If you mean you have 50+ users connected via WebSockets | and you need to send a message to each one | | I was thinking of, a client requests "give me a list of | my documents" or "share this document with Alice, Bob, et | al.", and the Worker that receives that request has to | handle that somehow. I thought that was tough to do in 50 | subrequests, but it's easy if I can just make an | unbounded number requests to different Durable Objects or | KV records. | | Edit: I found what gave me the idea about subrequests. | From the Workers docs: | | > For subrequests to internal services like Workers KV | and Durable Objects, the subrequest limit is 1000 per | request, regardless of usage model. | | https://developers.cloudflare.com/workers/platform/limits | /#h... | 9dev wrote: | Hey, just wanted to leave this here. It's pure joy to work | with Pages. I recently did a new homepage for my mom's beauty | salon and decided to use CF Pages, with a few functions for | booking requests and a contact form. It felt just... right. | Everything fell into place as I would have liked it to. Hits | the sweet spot between flexibility and pragmatism, in a way. | | Enjoy your week! :) | pjkundert wrote: | You can run workerd locally. | solardev wrote: | You can pretty easily change from Cloudflare to any other | Jamstack host. | | Cgi just isn't necessary anymore and would be more baggage than | anything at this point. | | The old web stacks are just time sinks. It's so much nicer to | be able to git push... And that's it. Done. | harryvederci wrote: | > It's so much nicer to be able to git push... And that's it. | Done. | | Can you elaborate? My CGI-based website is deployed with `git | push` as well, not sure what the difference is there. | 9dev wrote: | Is it, though? Who does git pull at the server? What | happens to in-flight requests during deployments? Traffic | surges? Requests from Nigeria? | solardev wrote: | How's your hosting stack set up? The Jamstack vendors are | zero config or maintenance | alehlopeh wrote: | Forgive my digression but for years I've seen small efforts | here and there to elevate the concept of a "stack" and | promote it as the level abstraction to use when discussing | web apps and the like. What's up with that? | | Grab any 3 commonly used pieces of technology whose names can | be used to form a fun initialism, append stack to the end, | and soon there will be experts speaking at conferences | dedicated to it. JamStack is an example you mentioned. I've | heard others over the years. | | I disagree that it's a useful unit of thought. No one I know | or work with ever talks about "web stacks" this way. Am I | missing something here? Is this just some kind of niche? | Who's marketing these? | solardev wrote: | What else would you call the well, stack, of technologies | used to host a website? It's not a marketing term, just a | way to describe the multiple layers. From hardware to | network routing to DNS to tcp/up to http to https to HTML | to JS to workers, and also Linux and PHP and a web server | like Apache or nginx and a database like Maria or Postgres | and maybe a cache like Redis or memcached and maybe squid | and Varnish in front of it... that's a stack. | | Jamstack is just a particular configuration where vendors | take care of all of that and you can push up frontend code | that auto deploys and that's that. I used to have to manage | the whole stack and now can work purely in HTML CSS and JS | and it is a DREAM. That's the magic of the Jamstack. Less | devops and network infrastructure, more time to focus on UX | and DX. | | As for vendors, there's Vercel, Netlify, Gatsby, maybe a | few others. Cloudflare, Deno, and Fly, Render and a few | others have similar variations. | | It's a really nice way to work... | ameliaquining wrote: | Jamstack in particular is not really an example of that; it | is more of a kind of architecture than a specific stack, in | that it doesn't prescribe the use of specific software. An | architecture where all the HTML/CSS/JS is precompiled | statically for maximum cacheability, and server-side | dynamic behavior happens exclusively within AJAX calls that | return structured data, is a natural kind, and useful to | have a term for so that we can compare and contrast it to | other ways of building web apps. | | More broadly, other acronym stacks are a thing because | complementary technologies cluster together, especially in | relatively immature ecosystems. E.g., PHP traditionally had | better support for mySQL than for competing databases, so | if you were building an app in PHP, you probably used mySQL | for data storage. These effects may have weakened over time | as the graph of ecosystem integrations has grown more | complete (and indeed I feel like I hear less about acronym | stacks these days than I did half a decade ago), but I | don't think they've died out entirely. | int_19h wrote: | The reason why PHP was bundled with MySQL historically is | not so much because it had better support for it, but | rather because cheap & free hosting would generally offer | MySQL (rather than, say, Postgres) - because it was | easier for _them_. If SQLite showed up a bit earlier, I | bet that would have become the standard. | megous wrote: | It's been around since forever. Things like LAMP (Linux | Apache MySQL PHP), etc. | qbasic_forever wrote: | For better or worse fast CGI never took off much beyond PHP. | Python, node, ruby, etc. all do their own thing with their own | app servers and protocols. I mean sure something like python | can use fast CGI but no one in that community uses it that way, | everyone uses uWSGI, gunicorn, etc. | | Plain old CGI doesn't scale beyond toy usage--it spawns a | process per request. | | So there really isn't a good single option for Cloudflare to | use. | rakoo wrote: | > Plain old CGI doesn't scale beyond toy usage--it spawns a | process per request. | | I'd be willing to bet the opposite: CGI is more than enough | for 80% of workload, performance-wise. | | There are a few good reasons why CGI isn't the best today: | the tooling doesn't exist, the security model is really bad, | and you can cram fewer websites on a single machine, so for | the same number of websites you need more machines, and | that's an ecological aberration. But there is no problem | about CGI being too slow. | qbasic_forever wrote: | Sure but developers don't want to bifurcate their service | code and releases into a simple version using CGI and a | dedicated app server version for when CGI doesn't scale for | them or their users. They just want to write one python web | app and run it everywhere. | | There's no way a CGI app can reach a million requests a | second on the same hardware that a nodejs (single thread, | worker loop) would take to do 1M RPS. Processes have a lot | of overhead. Almost no one needs 1M RPS but it cannot be | waived away that CGI is perfect for everything. | ameliaquining wrote: | Because V8's low-overhead tenant isolation is fundamental to | how Cloudflare Workers works[1], and without it it would be a | completely different product with worse performance. This means | it can only support JavaScript and WebAssembly. | | You can run it locally[2], and efforts are underway to | standardize much of it so that the same code can run on | Workers, Node.js, and Deno[3]. The Workers runtime is also open | source[4], although in practice this is likely to be less | useful for most use cases than just using one of the other | JavaScript runtimes if you're self-hosting. | | [1] https://developers.cloudflare.com/workers/learning/how- | worke... [2] | https://developers.cloudflare.com/pages/platform/functions#d... | [3] https://wintercg.org/ [4] | https://github.com/cloudflare/workerd | hackyhacky wrote: | Potentially stupid question: how is this different from hosting a | static site on S3 and using CloudFront as a CDN? Assuming I don't | need server-side JS, I don't see the benefit. | donmcronald wrote: | IMHO, when I use AWS I feel like I spend a lot of time dealing | with the infrastructure. For example, you have to create the | bucket, add IAM users that can deploy to it, set up CI that can | do that deploy, configure CloudFront, etc.. | | With CloudFlare Pages you click a couple buttons in the UI and | push to GitHub. When I tested it, I didn't get bogged down | managing infrastructure which I've always struggled with | (overthinking) in the past. I was almost instantly writing code | that solves my problem(s). | | The advantages aren't as huge with a purely static site, but | they're still there IMO. | truthwhisperer wrote: | schwartzworld wrote: | > As a shortcut, I used GPT-3 to generate a basic typescript | function for me. | | I'd love to see a more detailed post about that. I don't know any | TS devs using that kind of workflow. | Filligree wrote: | To write functioning code, you need to know how to write | functioning code. | | The biggest issue with Copilot is that, to use it well, you | need to know: | | - How to write functioning code. | | - How to quickly review other people's code for correctness. | | - How to write good comments. | | - How to tweak the ordering in which you write code such that | it's easier for Copilot to understand. | | - How Copilot and other GANs work, in general. An awareness | that Copilot is built on GPT-3, familiarity with what that | implies, and so on. | | And if you don't, that results in _the AI_ seemingly not | working as well, which makes it easy to make the assumption | that it isn 't an incredibly useful tool. It is, it just has a | learning curve measured in weeks. | | I believe this is why we constantly have arguments on whether | or not it's helpful. | threatofrain wrote: | The Cloudflare cloud experience is "being sold short by subpar | documentation" right now because important elements of their | ecosystem are being ramped up from beta status. They also have | internal docs which aren't kept up to date with their actual | product. I'd check back in a few months because their beta | experience can be _very_ touch-and-go. | Leftb wrote: | Agreed. One area where it's maybe not sold short but just | hurting the UX; it's not immediately clear from their | documentation that certain NextJS features you get | 'automatically' on Netlify/Vercel just aren't supported yet. | For example, using any kind of dynamic routing (i.e. going to | `/books/:id` directly rather than clicking through) doesn't | work yet as there's no router available to tackle this for you. | According to their Discord, it's in the works but it has been | in that state for a few months already. | | You can work around this with some Workers that capture the | dynamic routes, request the nextjs html file and return that, | but then you're using up your Functions quota as well. | iot_devs wrote: | Those function don't suffer from cold start time? | | When somebody hit my webserver for the first time, how long are | they gonna wait for the page to be loaded? | | Assuming a noop in the functions part. | tyingq wrote: | It uses clouflare workers, which is just spinning up v8 | isolates, so there's no VM booting up. It's fast. They are also | edge located. There are scenarios where using the kv or durable | objects can cause a round trip back to the mothership, but not | for reads. | | https://developers.cloudflare.com/workers/learning/how-worke... | rs_rs_rs_rs_rs wrote: | I like Pages, I hope they'll support hosting multiple projects | from different branches of a repo at some point... | Walshy wrote: | We will :) | gkoberger wrote: | 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 | tarasglek wrote: | Author here. I actually thought about using this library. In my | case re-rending as svg was too complex. Much more practical to | upload screenshots of DOM, share those via | functions/middleware. | elondaits wrote: | I'm happily using CloudFlare pages. The reason I haven't tried | Netlify is that after the free tier everything seems a little | overpriced. I didn't go for Vercel because I don't want to use | Next.js and I'm afraid I'll run across some limitation because | of this. I was already using Cloudflare as a CDN for S3 and | GitHub pages, and their offerings seem to be growing quickly | and wanting to compete with Amazon rather than the static | hosting companies. | jokethrowaway wrote: | Vercel is pretty good as a generic static hosting. I run a | handful of next.js, solid.js or vanilla html websites. | | Can't think of anything next.js specific you miss out on, you | can just configure anything in a vercel.json file. | emptysongglass wrote: | If you don't want to deal with any of that but like MDX | (think Markdown with the option of JavaScript), I believe | motif.land publishes your MDX sites with Vercel. | leerob wrote: | All of the Vercel platform features you can use in Next.js | (or other frameworks) are also available through the Build | Output API for frameworks to target. This is what | frameworks like SvelteKit, Nuxt, Solid, etc use on Vercel. | | https://vercel.com/blog/build-output-api | cj wrote: | Static hosting combined with server-side dynamic content | modification using postgres was the interesting part for me. | | Static hosting has historically been seen as exactly that, | static and immutable. | | Things like Cloudflare functions/workers can turn static | hosting into dynamic content delivery while maintaining (most | of) the benefits of static hosting. | | Granted, this can be done whether the underlying content is | hosted on Cloudflare, AWS, or a server in your garage so long | as it's proxied/CDN'd by a service like Cloudflare or | Cloudfront+Lambda@edge, etc. | datalopers wrote: | I'm still struggling to understand how this is any different | than an oldschool cms or blog with a cache in front. | habibur wrote: | no add + free. | | Plus CDN if that matters. | quickthrower2 wrote: | Having stuff served up near the user for speed, for one. | | Also DX being better | rapind wrote: | It's not. You can achieve the same or better results with | Varnish. You can even achieve edge caching with Fastly | (cloud varnish). | | I think of it just as a different approach, where the focus | is static (cache) with dynamic layered in as necessary. | This forces you to be more explicit about dynamic behaviour | and treating cache as a priority concern. | sofixa wrote: | 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. | huijzer wrote: | > 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. | gadflyinyoureye wrote: | This comment is about serverless in general, not this | particular tech. I've been abusing serverless for three | years now using a NestJS bridge to the API gateway. All | API request get bulk routed to a single lambda. NestJS, a | dependency injection system for Node, handles particular | routing, JWT validation, etc. Then my code does all the | backend stuff. If I ever need to move from AWS lambda to | EC2 (due to payload size or sync call limitations), I | can. Neat JS will boot normally. Little to no vendor | lock-in, especially in the domain later thanks to Clean | Architecture. | gfodor wrote: | 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. | neongreen wrote: | Vercel serverless functions: | https://vercel.com/docs/concepts/functions/serverless- | functi... | gfodor wrote: | That's not middleware, is it? It's cool, but sits between | what is discussed here and something like a FaaS. My | understanding is that this post is about actually | deploying middleware that runs during the serve of the | static pages. | OrvalWintermute wrote: | This sounds similar to the old Server Side Includes [1] . | | In the 90s I was using SSI to build dynamic, but static sites | | -- header -- | | -- hierarchal javscript menuing -- | | -- content -- | | -- footer -- | | -- tail -- | | [1] https://en.wikipedia.org/wiki/Server_Side_Includes | pythonaut_16 wrote: | Can you explain how Cloudflare Workers factor into hosting | static pages on Cloudflare Pages vs hosting a React SPA on | pages that talks to any other API? | | Like are the workers just serving as your backend at that | point? Or are they doing something more or different as well? | whimsicalism wrote: | the workers are regenerating the static site on postgres | push | pythonaut_16 wrote: | Ah, so still fully static vs. a SPA that uses REST or | GraphQL. So then clients interact with it as static | HTML/JS rather than hydrating it via Javascript. | gfodor wrote: | 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. | darkerside wrote: | It's funny, the simplicity really reminds me of server size | scripting languages like ASP and PHP. | sramam wrote: | a bit off-topic, but couldn't resist: | | > As a shortcut, I used GPT-3 to generate a basic typescript | function for me. This let me look at TS type definitions and get | a better idea of what's available so I could get developing. | | As a long time programmer, I keep trying to maintain my | skepticism of AI/ML techniques for program authoring. Comments | like this are dissolving my objections by the minute... | tarasglek wrote: | See my comment re GPT above. It has saved me quite a few hours | since I started using it. | johnebgd wrote: | Cloudflare continues to add capabilities to their free tier to | attract users. Meanwhile, Netlify just ejected all of the free | plan users who work off GitHub. | musicale wrote: | I wonder why the article (or glek.net in general?) takes so long | to load. | quickthrower2 wrote: | You must be a long way from the edge :-) | Cthulhu_ wrote: | Title has been editorialized; there is no question mark in the | original, and the capitalization is different. | | As people smarter than me have said, if a video or in this case | article asks a question, the answer is usually "no". | [deleted] | ArtWomb wrote: | Reminder: Cloudflare's "Worker's Launchpad" application for | inaugural cohort approaches | | https://www.cloudflare.com/press-releases/2022/1-billion-wor... | | Recent thread on Learning Blender 3D has me thinking that a kind | of "Blender Mentor" exchange with live zoom critiques & happy | hour may be fun ;) | | https://news.ycombinator.com/item?id=33273022 | EarlKing wrote: | untitaker_ wrote: | What is really annoying is that Cloudflare pages will strip the | file extension off of your html pages, and perform permanent | redirects to those new URLs. Now if you're intending on moving to | a new hosting service that doesn't do that (cgi-bin), all Google | search results to your site will 404. | | Github pages and likely others also supports this format, so | moving between those two services doesn't exhibit this problem. | Moving to cgi-bin will. | | I'd suggest Cloudflare shouldn't try to establish their scheme as | canonical url and rather implement github pages behavior, but | what do I know... I'm just hosting an old fashioned blog, not a | JAMstack/SPA/whatever thing | tannhaeuser wrote: | Maybe I'm misunderstanding, but Apache httpd has performed URL | rewriting such as adding a .html suffix after mapping URLs to | file names where appropriate, and other transformations such as | content negotiation for languages, spelling correction, etc. | for ages. | untitaker_ wrote: | Cloudflare automatically redirects any /foo.html URL to /foo, | with a permanent redirect. That is certainly not standard | behavior, neither on httpd nor gh pages | sofixa wrote: | Having .html file extensions is very old school, and its | removal is one of the popular/default redirects on all http | servers that support it. Site generators also hide it through | various methods (e.g. having a folder with the path name with | just an index.html where a dynamic redirect isn't possible). | systemvoltage wrote: | "Old school vs. new school" arguments should be replaced with | "Pros vs Cons". Call me, old schooled. | untitaker_ wrote: | Site generators hiding it is not a problem for portability. | Supporting that redirect is also not a problem! Permanent | redirects are. | | Also, old-school is still the dominant way with how small | sites are hosted, in terms of number of hosting providers who | offer cgi hosting. | qbasic_forever wrote: | It was removed explicitly for SEO and having a single | canonical URL for a resource _for all of time forever_. Right | now we use HTML for web pages but who knows what the internet | 20, 50, 100, etc. years from now will use--maybe .Super- | Awesome-Mega-HTML is all the rage. If over time you are | changing your site and its URLs are changing then you're | breaking that canonical URL and search indexes, caches, way | back machine, etc. all suffer. So the intent is don't make | the format of the page (HTML) part of it's canonical URL. | superkuh wrote: | Yes. New school's defining feature is needless layering of | complexity to hide the simple truth of the file system from | users. | texaslonghorn5 wrote: | Maybe this is just me, but I like that I can decouple the | way I organize my file system from the way users access my | site. And with that comes the ability to get rid of file | extensions and make urls more human-friendly. Remember, not | every person has file extensions turned on by default on | their Windows File Explorer! | P5fRxh5kUvp2th wrote: | texaslonghorn5 wrote: | Ok, I set myself up for that. | | Do you have experience running websites that cater to the | non tech savvy? How are your urls set up? Do they get | confused where to find things? Do you use a database? Do | you dynamically render content using templates? | jon-wood wrote: | Not the GP here, but having run websites for the non tech | savvy I can say they have no problems with any sort of | URL structure because they are oblivious to URLs. They | enter your-site.com into Google, click the first result | (even if that's an ad for your competitor), and then | click round the links presented. | neilalexander wrote: | Is there a reason why someone visiting your website should | know or care about file extensions? | lenkite wrote: | I guess no one should know whether a pdf is a pdf. Or | even whether it's a .com or a .org domain - the browser | should just strip all that confusing stuff away! | texaslonghorn5 wrote: | When you're serving someone an HTML file are you serving | them the exact copy on your file system or do you ever | use templates? Do you ever pull info from the database? | If so, can you see why this is slightly different from | directly serving a static pdf? | | Also note that you'll often see a PDF generated on the | fly with a long, difficult to parse URL. | | Take up your second point with the W3 or whatever, to be | honest if tlds weren't so important for phishing and | whatnot it would probably be fine. I think some browsers | have started doing that anyway. You overestimate how tech | savvy the average user is, and by extension you | overestimate how much the average user can keep track of | all this complexity. Do you think most people have heard | of .info or .xyz? | lmm wrote: | The user presumably wants to know what kind of content | they're going to receive from a given endpoint - | foo.html, foo.pdf, foo.jpg, foo.mp3 and foo.avi suggest | quite different experiences, and it's nice to include | that hint in the URL (where it's visible on mouseover) | rather than the user having to go in blind. I also like | being able to reassure the user that they're receiving | the same piece of content however they access a given | resource, rather than the possibility of invisible | content negotiation changing the site's behaviour. | neilalexander wrote: | Such hints can be unreliable at best and misleading at | worst. There is nothing to guarantee that the file | extension and the Content-Type header will agree, nor is | there anything to guarantee that the file name in the URL | will match the download file name in the Content- | Disposition header. | lmm wrote: | Well, sure, but you can just... not do that? The <title> | tag can be misleading because there's no guarantee that | the title matches the content of the page - but the | answer to that is to use good titles for your pages, not | to avoid using the <title> tag. | neilalexander wrote: | My point is that it isn't really reassuring for the user | because of invisible negotiations. If anything, I would | lean more towards guessing that users are, more often | than not, either ignorant or untrusting of URL contents, | either because the URLs so frequently look like nonsense | (arbitrary content IDs instead of meaningful names) or | because they have already proven to be unreliable | elsewhere on the web (deep links not as deep as expected | when copied or shared). | lmm wrote: | > If anything, I would lean more towards guessing that | users are, more often than not, either ignorant or | untrusting of URL contents, either because the URLs so | frequently look like nonsense (arbitrary content IDs | instead of meaningful names) or because they have already | proven to be unreliable elsewhere on the web (deep links | not as deep as expected when copied or shared). | | I think users are (rightfully) distrustful of URLs in the | general case, but a URL having a file extension is | actually a pretty good indication that it's a simple | "does what it says on the tin". (Imgur changing their | .jpg URLs to have more complex behaviour caused a pretty | big backlash, for example) | slig wrote: | Can't you use their new Bulk Redirects to fix it? | kc10 wrote: | I exactly ran into this issue when migrating from a different | provider to CF pages. | | I preferred to strip away the .html extensions anyway, so it | was okay in my case. CF should trigger a HTTP 308 for older | .html to the new urls automatically. | dixie_land wrote: | Having worked with some J2EE early in my career, I also had | trouble mentally mapping "middleware" to an "interceptor" | function when first encountering these "hip" frameworks | sophacles wrote: | Middleware is a concept far older than java. | sgt wrote: | Also think Servlet filters | andrewstuart wrote: | I tend to agree. | | Cloudflare services are awesome. | | Their documentation tends to be OK but thin. Certainly not great. | Walshy wrote: | We're working on the documentation, I agree it can certainly be | thin (or just not understandable). Please do file an issue for | any improvements you'd like to see: | https://github.com/cloudflare/cloudflare-docs/issues | andrewstuart wrote: | I like documentation with lots of complete examples of every | option. | | Reference guides with every object/function/method | documented. | | Links to sample code on github. | ZephyrBlu wrote: | For Workers I've found that their docs are anything but thin. | Extremely comprehensive and very helpful. | londons_explore wrote: | In 10 years time when cloudflare goes bankrupt/withdraws the free | offering, will you be able to redeploy to another platform or | will you start having to delve into 10 year old code and porting | it to a new API? | | Is there at least an nginx-cloudflare module that lets you self- | host this stuff? | pantojax45 wrote: | How does using GPT-3 make the types more visible? Feels | futuristic but also incomprehensible to me. | | > As a shortcut, I used GPT-3 to generate a basic typescript | function for me. This let me look at TS type definitions and get | a better idea of what's available so I could get developing. | lelandfe wrote: | Hope the author responds, because that stuck out to me too! | | My assumption was that their prompt was something like | "typescript cloudflare function" and they just used the | resultant code to see types in action inside their IDE. | wilg wrote: | GitHub Copilot is GPT-3 under the hood, so maybe that way? | tarasglek wrote: | I use copilot, but not for this. I find raw gpt-3 | conversational interface to be much more useful for getting | over various small programming puzzles. | Filligree wrote: | Prompted correctly, I find that Copilot can do pretty | much everything GPT-3 can except generating long-form | prose. | | You're probably right that it's more flexible, but then | again I don't want to constantly switch out of IDEA. | tarasglek wrote: | Author here. | | I just got access to OpenAI codex. I used edit function and | asked it to modify the JS hello world, to add typescript | annotations. | | This is the git commit following that gpt conversation :) | -export async function onRequest(context) { +export | async function onRequest(context: { + request: | Request; + env: { [key: string]: string }; + | params: { [key: string]: string }; + waitUntil: | (promise: Promise<any>) => void; + next: () => | Promise<void>; + data: { [key: string]: any }; | +}) { | | Not as minimal as the code I posted, but it got me over the | stumbling block. | jopsen wrote: | lol, I was 50% sure that you were being sarcastic about | using GPT-3, hehe | | But if anyone is edgy enough to use AI as a shortcut, I | guess it would be the guy who did telemetry ingestion on a | t2.micro :D | | Regards Jonas, | harwoodjp wrote: | Cloudflare Pages and Workers (and similar products) are indeed | great but I recently switched over to a plain old free tier | Oracle Cloud VM with FastAPI behind Nginx (Docker containers). I | use Cloudflare as a proxy for HTTPS/certs. I don't have to think | about Cloudflare Worker limitations, can host a Postgres | instance, and simply deploy through `git pull` and `docker- | compose up`. | andrewstuart wrote: | It's tempting to use the Oracle free instance but I wouldn't | use it for production cause I don't trust it will be free in | the long term. | jprd wrote: | But now Oracle has your financial information. I would rather | give my Social Security number to a Nigerian prince. | | There's a reason Larry Ellison owns an entire Hawaiian island, | and it ain't nothin' nice...it ain't nothin' nice (#QTip) | alphabettsy wrote: | Using Fly.io myself, behind Cloudflare. Free container hosting | and free Postgres instance both big enough for my needs. | svnpenn wrote: | Fly.io is weird about overages: | | https://github.com/superfly/docs/issues/382 | Comevius wrote: | 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. | donmcronald wrote: | I mostly agree. | | > Workers can also send emails for free, and soon you will be | able to process them as well with Email Workers. | | There's got to be _some_ limitations to that and I don 't like | it when they're not well defined. Looking at the MailChannels | pricing, it looks like it's roughly 40x more expensive than AWS | SES on the low end and 4x on the biggest plan before | negotiating a custom deal. | | I can send 500k emails and have a dedicated IP on SES for the | same cost as 40k emails from MailChannels. Since their big | value add seems to be scanning emails to prevent spam from user | generated content, I just don't see it if that's not | functionality you need because it's all wasted resources / | unnecessary cost in those cases. | | I assume there's a point where it's no longer free and I'm | guessing the cost once you get there will be high. | | Plus, am I sharing IPs with people who are sending such low- | quality mail it requires outbound spam filtering? That seems | like a huge negative on the deliverability side of things. | jgrahamc wrote: | I agree. | matthews2 wrote: | We just don't want to support MiTMFlare with our traffic and | money. | Comevius wrote: | This should help you then. 200 square feet, only $11.39. | | https://www.amazon.com/Reynolds-Wrap-Aluminum-Foil- | Square/dp... | [deleted] | rs_rs_rs_rs_rs wrote: | Cloudflare reports 50% quarter growth year over year, it | sounds to me you're in a minuscule minority. | matthews2 wrote: | Yes, let's simplify the Internet, being decentralised is | such a crutch! We should all just connect directly to | Cloudflare. | rs_rs_rs_rs_rs wrote: | You go ahead and play "being decentralised" with your | buddies while people in the real world just mind their | own business doing whatever they need to do using the | current right tool for the job(in this case Cloudflare | being the tool). | dzikimarian wrote: | People in the real world, who just cheerfully do | business, with zero thought of impact or consequences of | their actions beyond next paycheck, have put us in this | awesome economic situation, we all know and enjoy. | | Surely blindly pushing, yet another corporation into | position, where they can lobby virtually anything, is | awesome idea. (Nothing against folks from cloudflare. | They seem all right, but they will get acquired and/or | change leadership at some point). | anderspitman wrote: | In nature, a lack of genetic diversity in a species isn't | typically much of a problem until there's an extinction | event, and then it can be a big problem. | | You might not feel the downsides of having a huge | percentage of the internet going through a single | provider until it's too late to change it. | | I actually quite like Cloudflare, and I don't think | they're purposely doing anything nefarious (just | following incentives like everyone), but I think caution | is warranted. | quickthrower2 wrote: | At least it is not Microsoft, Google or Meta providing | the monopoly! For now... | schwartzworld wrote: | Getting angry at people for using centralized solutions | is not a way to win people over to your cause, and even | many people who would prefer decentralized solutions are | going to pick the easy route sometimes. If you're | developing a web app, maybe you want to spend your time | writing app code. People only have so much time in a day. | blueflow wrote: | That the majority does it does not mean its a good thing. | rs_rs_rs_rs_rs wrote: | It absolutely is, Cloudflare offers great services and | they deserve it! | anderspitman wrote: | I think parent meant as a general principle following the | masses isn't always the best idea. | sophacles wrote: | I'm always curious how you folks would CDN without SSL | termination. Or you know, host anywhere but your own gear if | MiTM was a real concern. | anderspitman wrote: | There's a huge amount of websites that don't need a CDN (my | blog has frontpaged multiple times without one). And for | many (all?) of the rest you'd be fine with 3-5 regions. | CDNs _increase_ latency for low-traffic sites. | quickthrower2 wrote: | Weary of free as in beer. Often it is better to pay, for a | situation where you are the actual customer. | pid-1 wrote: | wishlist: static page hosting for internal pages (e.g behind IP | allowlists, SSO, etc...) | 9dev wrote: | That is integrated in Pages, it offers to set that up using | Cloudflare Access. Fulfills your wishlist, and more. | | (Not affiliated) | jacooper wrote: | 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. | metadat wrote: | Yeah, I have a few WordPress sites that would be great to move | to SQLite (durable objects) / workers+functions. | | My sense is it's still a ways out from being practical, though. | sofixa wrote: | 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. | colesantiago wrote: | This. | | I keep seeing these 'JAMstack' sites are the new hot thing when | a static wordpress site is enough and easier to update than | 'JAMstack' sites, in reality these sites are just glorified | HTML under a CDN. | | I don't see the benefit of JAMstack when you can just place a | static WP site under a CDN like Cloudflare and have all the | benefits of WP and a CMS to edit content. | | At least with Cloudflare they are more than just a CDN, others | like Netlify and Vercel seem to be both over engineered and | overpriced for what they do. | solardev wrote: | They solve different problems. WordPress is a full stack | solution that's great for blogs and simple websites. The | downside is that it's a lot of maintenance (requiring a LEMP | stack) and not very portable. You have to copy over | everything from the code to the database to the files to | things like htaccess and nginx config. Hosts Like Pantheon | and wpengine make that easier, but you're still bogged down | by overhead. Scaling is really hard if mere caching doesn't | work because you have to deal with Mysql replication and | slaving. And what's really annoying about this setup is that | you HAVE to deal with the whole stack. If the content writers | want to preview their changes, you have to a clone them a | staging environment. That means DB merges or overrides. And | if you're simultaneously making other changes to the | production DB, good luck reconciling the two. | | Jamstacks really shine when you can decouple the frontend | from the backend(s), because then you have an easily | replicable single repo with nothing but code. You can deploy | it to any Jamstack host with a push and they handle all of | the scaling and https and caching concerns. And the backend | teams, whether an in house endpoint or content writers | working on a hosted headless CMS, never have to care about | the stack. | | A middle ground that's interesting to explore is using | WordPress with Advanced Custom Forms as a backend plus a | Jamstack frontend. ACF is still quite a bit more powerful | than any of the headless CMS solutions I've tried, but it | does mean you still have to maintain a LEMP stack, which is a | headache in and of itself. | girvo wrote: | As much as I dislike it personally, WordPress's admin | portal and plugins like ACF (among others) are simply | unbeatable when the end result is handing the keys over a | client, both due to power and familiarity. | | I wonder if that will change given enough time. I certainly | hope so, but I would've guessed that it would've changed | already, but here we are in 2022... | nixcraft wrote: | 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 | newly introduced "Cache Rules" beta | https://developers.cloudflare.com/cache/about/cache-rules/ | | Also check - a WordPress plugin for static site generation and | deployment https://github.com/WP2Static/wp2static | ianbutler wrote: | 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... | kentonv wrote: | Thanks for catching this. Not sure what happened exactly but | jiggling the handle (republishing the post) seems to have fixed | it. | ianbutler wrote: | Yup, and thank you for fixing it! | quickthrower2 wrote: | 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. ___________________________________________________________________ (page generated 2022-10-23 23:00 UTC)