This is really cool...but why ?
I worked for an analytics company at one point and we generated impression IDs server side (you'd be surprised how broken client-side JS randomness can be) and included them in our loader. If we had been using CloudFlare I would have put our loader directly into this service worker so that we could shave a few more milliseconds off our intial response time, so that we could get to our cached JS faster. So yeah, if yo…
Cloudflare Workers: Run JavaScript Service Workers at the Edge
51–60 of 134 posts
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#52Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#53This is really cool...but why ?
I thought of a few use cases... A more granular way to block requests than what cloudflare provides (IP, BGP AS, country) Tokenizing credit cards at the edge if you have a payment provider that supports that, and are using CF's PCI compliant environment. Injecting a unique ID into requests for log correlation. You get collisions if you do this via browser javascript for various reasons. I'm assuming v8 has a better M…
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#54This 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 wish I'd included more images and diagrams in the post, but I'm generally terrible at coming up with those.
I also wish we'd been able to enable it in production for everyone immediately... but with a change this big we need to be cautious.
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#55Earlier quoted context omitted.
Will there be any limits on memory/execution time etc like with AWS Lambda?
Yes. Currently you get at most 50ms CPU time per request, and memory usage of your Javascript VM is limited to 128MB. These numbers may change before launch. In practice, though, a typical script probably uses much less than 1ms of CPU time per request and probably needs only a couple megs of RAM. Because we're applying limits on the level of a V8 Isolate, not on an OS process, the limits go a lot further. Keep in mi…
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#56Hey all! This is my project at Cloudflare. (You may remember me as the tech lead of Sandstorm.io and Cap'n Proto.) Happy to answer questions!
I'd be curious to learn more about the implementation (did you lift the existing SW implementation from blink somehow, or reimplement it)?
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#57Hey all! This is my project at Cloudflare. (You may remember me as the tech lead of Sandstorm.io and Cap'n Proto.) Happy to answer questions!
Hey Kenton, should've guessed you were behind this. Lovely design, great work. I'd be curious to learn more about the implementation (did you lift the existing SW implementation from blink somehow, or reimplement it)?
https://chromium.googlesource.com/chromium/src.git/+/lkgr/gi...
A bindings layer for v8 that was specifically intended to make implementing web-style APIs outside of Blink easier. At the time at least, refactoring things like SW out of Blink was ~impossible.
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#58Seems like this plus the Cloudflare Apps could yield some interesting projects.
Yup. :-)
I hope it's not priced too harshly. Hopefully an added monthly flat rate rather than per-request pricing?
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#59offtopic: can cloudflare be used as a CDN for just assets? The cloudflare docs talk only about using it as CDN for an entire site.
>SECTION 10: LIMITATION ON NON-HTML CACHING
>You acknowledge that Cloudflare’s Service is offered as a platform to cache and serve web pages and websites and is not offered for other purposes, such as remote storage. Accordingly, you understand and agree to use the Service solely for the purpose of hosting and serving web pages as viewed through a web browser or other application and the Hypertext Markup Language (HTML) protocol or other equivalent technology. Cloudflare’s Service is also a shared web caching service, which means a number of customers’ websites are cached from the same server. To ensure that Cloudflare’s Service is reliable and available for the greatest number of users, a customer’s usage cannot adversely affect the performance of other customers’ sites. Additionally, the purpose of Cloudflare’s Service is to proxy web content, not store data. Using an account primarily as an online storage space, including the storage or caching of a disproportionate percentage of pictures, movies, audio files, or other non-HTML content, is prohibited. You further agree that if, at Cloudflare’s sole discretion, you are deemed to have violated this section, or if Cloudflare, in its sole discretion, deems it necessary due to excessive burden or potential adverse impact on Cloudflare’s systems, potential adverse impact on other users, server processing power, server memory, abuse controls, or other reasons, Cloudflare may suspend or terminate your account without notice to or liability to you.
I think in practice, unless you have a very popular website or are abusing it in some way, they probably wouldn't care or even notice. But you'd still be taking a gamble.
(I don't work at Cloudflare though so take whatever I say with a grain of salt.)
Re: Cloudflare Workers: Run JavaScript Service Workers at the Edge
#60Hey all! This is my project at Cloudflare. (You may remember me as the tech lead of Sandstorm.io and Cap'n Proto.) Happy to answer questions!