Live data from Hacker News

Cloudflare Workers: Run JavaScript Service Workers at the Edge

blog.cloudflare.com

121–130 of 134 posts

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#121

Sounds like this could be a pretty trivial way to load balance React prerendering. As long as the react code fetches all data in 1 call it should be at least as efficient as doing it all in Nodejs on your server.

Could this be generalized to work across frameworks with e.g. https://github.com/prerender/prerender?

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#122
post #43

Earlier quoted context omitted.

Yes, your worker can make subrequests to other domains, and serving some assets out of S3 is a use case we specifically want to enable. I haven't looked into how specifically to expose HTTP Push in the API but that certainly seems like something we should support.

Please, add support HTTP/2 push! This is very, very awesome work. My team has been working on enabling the PRPL pattern[1] and differential serving on a few platforms, and edge caching has been a problem. We've tried to use Vary: User-Agent, but that leads to low cache hits. This API would let us to much smarter UA sniffing at the edge. From there we just need to parse some responses like JS and HTML, to be able to p…

Http/2 push is interesting here. Beyon static assists I wonder about read API orchestration or equivalent of graghQL on edge. I.e a single request comes in and it's broken apart against catchable resources and pushed back to the client from cache where possible.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#123
So, can I use this to do this:

Render your SPA (different index.html) when a login cookie is set and otherwise render your landing page (yet another index.html)? - Such that that my http://example.com can always be cached (unless it needs to hit the server where the same logic is implemented).

And in general, how do you manage your landing page vs. your SPA?

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#124
post #46

This is probably the best annoucement of a new feature I have ever read. It makes an analogy to an existing technology. It provides a clear description of the new feature. It provides clear examples of how to use the new feature with a link to a sandbox so you can run and modify the examples. And it explains the thought process behind the implementation. In additon, I didn't notice a single typo, spelling or grammar…

> I didn't notice a single typo JavaScript is spelled incorrect all over the place. Awesome feature and post!

That would be "incorrectly".... be careful with criticism.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#125
post #122

Earlier quoted context omitted.

Please, add support HTTP/2 push! This is very, very awesome work. My team has been working on enabling the PRPL pattern[1] and differential serving on a few platforms, and edge caching has been a problem. We've tried to use Vary: User-Agent, but that leads to low cache hits. This API would let us to much smarter UA sniffing at the edge. From there we just need to parse some responses like JS and HTML, to be able to p…

Http/2 push is interesting here. Beyon static assists I wonder about read API orchestration or equivalent of graghQL on edge. I.e a single request comes in and it's broken apart against catchable resources and pushed back to the client from cache where possible.

That's actually one of the canonical use cases we thought about while designing. It seems splitting graphql queries into cacheable chunks is a common need.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#126
post #123

So, can I use this to do this: Render your SPA (different index.html) when a login cookie is set and otherwise render your landing page (yet another index.html)? - Such that that my http://example.com can always be cached (unless it needs to hit the server where the same logic is implemented). And in general, how do you manage your landing page vs. your SPA?

Yep. At the origin you might serve the SPA as /spa.html and the worker rewrites the URL for people hitting /.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#127

Is this similar to Amazon's Lambda@Edge?

Sounds like it. I think Cloudflare's edge (no pun intended) is going to be their 110+ locations to host this. As opposed to Amazon's 93 I believe? (If all cloudfront spots support lambda@edge that is) https://aws.amazon.com/cloudfront/details/

I would say at 117 edge locations vs 93 Cloudflare will have lower latency, but most notable in markets that most companies care least about. Probably of more importance is by using embedded V8 as opposed to a process-level sandbox running Node.JS, the Cloudflare service worker will have a much faster startup time in all locations. I seem to recall from tests in Lambda that we're looking at 40-50ms, which is actually substantial given how close these locations often are to the user. But the biggest edge in my books is CloudFront bandwidth is ridiculously expensive and Cloudflare doesn't charge (directly) for bandwidth. Bandwidth often being the single biggest line item in your AWS bill if you get a lot of traffic.

Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge

#129

Earlier quoted context omitted.

> I didn't notice a single typo JavaScript is spelled incorrect all over the place. Awesome feature and post!

That would be "incorrectly".... be careful with criticism.

do you mean that one must be completely flawless?
Post reply on HN