TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Cloudflare Workers: Run JavaScript Service Workers at the Edge

327 pointsby thomseddonover 7 years ago

29 comments

js2over 7 years ago
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&#x27;t notice a single typo, spelling or grammar error.<p>Also, this feature is pretty cool!
评论 #15366125 未加载
评论 #15367636 未加载
评论 #15368402 未加载
kentonvover 7 years ago
Hey all! This is my project at Cloudflare.<p>(You may remember me as the tech lead of Sandstorm.io and Cap&#x27;n Proto.)<p>Happy to answer questions!
评论 #15365085 未加载
评论 #15365602 未加载
评论 #15366306 未加载
评论 #15366670 未加载
评论 #15365322 未加载
评论 #15366442 未加载
评论 #15370348 未加载
评论 #15365190 未加载
评论 #15365414 未加载
评论 #15365316 未加载
评论 #15366626 未加载
Erwinover 7 years ago
Obligatory transformation of cloud to you-know-what:<p><a href="https:&#x2F;&#x2F;cloudflareworkers.com&#x2F;#9bdc354e936c05a4a1d7df7eb0d7f672:https:&#x2F;&#x2F;blog.cloudflare.com&#x2F;introducing-cloudflare-workers" rel="nofollow">https:&#x2F;&#x2F;cloudflareworkers.com&#x2F;#9bdc354e936c05a4a1d7df7eb0d7f...</a>
评论 #15366646 未加载
niftichover 7 years ago
Kudos for re-using an existing API when one was already available in the same language for a very similar usecase.<p>Any time you commit to someone else&#x27;s API -- whether it&#x27;s an actual industry standard, or simply some de facto widely used paradigm -- you incur risks; conversely, now that you&#x27;re a vested participant, consider being involved in the future of the spec so it can evolve where it needs to meeting emerging needs around its new uses.
评论 #15365699 未加载
j_sover 7 years ago
Paging HN user johansch from his comment on the Cloudflare Apps mitm JavaScript injection discussion 3 months ago:<p>johansch: <i>All I want is my code running on your nodes all around the world with an end-to-end ping that is less than 10 ms to the average client</i><p>dsl: <i>Akamai Edge Compute is what they are asking for</i><p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14650025" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=14650025</a>
manigandhamover 7 years ago
This is fantastic. Fastly is great but hard to use with Varnish VCL, and no other CDN had any real scripting capabilities. The service worker API is also a lot better than serverless cloud functions or lambda@edge.
narsilover 7 years ago
Great product announcement post! I especially liked the Q&amp;A section&#x27;s reasons for not choosing alternatives.<p>Is the lack of maturity also the reason for not choosing something like vm2 for NodeJS <a href="https:&#x2F;&#x2F;github.com&#x2F;patriksimek&#x2F;vm2" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;patriksimek&#x2F;vm2</a>
评论 #15367782 未加载
TheAceOfHeartsover 7 years ago
This sounds like a really powerful feature. I love how it uses JavaScript, which makes it much more approachable for web developers.<p>My experience with Service Worker APIs hasn&#x27;t been very positive, although I don&#x27;t have any suggestions for ways it could be improved, so I apologize for the non-constructive feedback. Maybe after using it more I&#x27;ll change my mind. I recognize that everyone involved is likely working hard to provide an API that&#x27;s capable of handling a wide range of problems, many of which I likely haven&#x27;t even considered.<p>Here&#x27;s a more actionable complaint: fetch doesn&#x27;t support timeout or abortion. I have a hard time understanding how this isn&#x27;t a problem for more people. Say what you will about XMLHttpRequest, at least it supports these basic features. As an end-user, I always find it absolutely infuriating when things hang forever because a developer forgot to handle failure cases.<p>I&#x27;d love it if you published a locally runnable version. Aside from making it easier to configure and experiment, it would give me peace of mind to know that I could continue to use the same configuration if Cloudflare decided to terminate my service.
评论 #15369547 未加载
wcdolphinover 7 years ago
Could this be used for HTTP Push across domains? I would love an easy way to take advantage of HTTP Push for assets hosted on S3 without routing requests to my origin server.
评论 #15365955 未加载
Gysover 7 years ago
So in a way this is similar to for example AWS Lambda ? It can process incoming http requests in many ways ? Fascinating idea.<p>Is there any indication on price level ? And what about runtime duration ?
评论 #15365247 未加载
throwaway84736over 7 years ago
Have you guys considered side channels?<p>Seems like whenever there&#x27;s co-execution (VMs, JavaScript, etc) there seem to be side channel leakages.
评论 #15365494 未加载
polskibusover 7 years ago
I read the article, but I&#x27;m not sure what this technology is enabling really. Can it be thought of as a new player in the lambda&#x2F;serverless category? Does it have any advantages to using other serverless stacks like aws lambda or azure?
评论 #15368487 未加载
评论 #15368424 未加载
poormanover 7 years ago
Seems like this plus the Cloudflare Apps could yield some interesting projects.
评论 #15365533 未加载
评论 #15365490 未加载
skrebbelover 7 years ago
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.
评论 #15368574 未加载
评论 #15371794 未加载
peterwwillisover 7 years ago
<p><pre><code> - Is it &quot;Cloudflare Workers&quot; or &quot;Cloudflare Service Workers&quot;? A &quot;Cloudflare Worker&quot; is JavaScript you write that runs on Cloudflare&#x27;s edge. A &quot;Cloudflare Service Worker&quot; is specifically a worker which handles HTTP traffic and is written against the Service Worker API. </code></pre> Consufing naming convention. Now you have to say &#x27;worker worker&#x27; or &#x27;non-service worker&#x27; so nobody has to wonder if you meant &#x27;service worker&#x27; when you only said &#x27;worker&#x27;.
评论 #15368366 未加载
forcerover 7 years ago
Could this be used to make Cloudflare respond to HTTP POST requests?
评论 #15368061 未加载
drdaemanover 7 years ago
Oh my. Is there any form of persistence, present or planned?<p>If there is - this means that there (eventually) will be a way to have logs from the edge servers. I&#x27;m just thinking about a worker that would collect the requests and responses data in some circular buffer, and try to push it to the origin server. Eventually, the data will get through, so no CDN-returned 52x (&quot;web server is not responding&quot; etc) errors would go unnoticed.
评论 #15367396 未加载
renke1over 7 years ago
So, can I use this to do this:<p>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 <a href="http:&#x2F;&#x2F;example.com" rel="nofollow">http:&#x2F;&#x2F;example.com</a> can always be cached (unless it needs to hit the server where the same logic is implemented).<p>And in general, how do you manage your landing page vs. your SPA?
评论 #15380927 未加载
评论 #15373651 未加载
mxuribeover 7 years ago
This is really interesting; kudos to Cloudflare for launching what seems like a cool thing!<p>Also, agree with other commentators here; nicely-written blog post!
tyingqover 7 years ago
Very nice. Are there plans to expand on it? For example, some way to allow state to be kept at the edge as well.
评论 #15365451 未加载
valentinvieriuover 7 years ago
Great addition to your services. I really want to see the pricing. Also I&#x27;m quite excited to see how this will play along with the apps concept. Do you plan also to introduce a monetisation system for the apps? It will be a good incentive then for developers to get some nice income.
评论 #15369829 未加载
ohnoesjmrover 7 years ago
Sounds very cool, but first thing that hit my head: Sounds like a perfect tool to DDoS someone?
评论 #15367473 未加载
fowl2over 7 years ago
This is really cool! I wonder if this will become the new &quot;S3 API&quot; and get everyone to copy^H^H^H^H implement it.<p>Also a little concerned about writing anything substantial without an onprem version!
评论 #15384919 未加载
hdhzyover 7 years ago
This is excellent news! Now I wish AWS Lambda and alternatives also supported Service Worker API (Google Cloud Functions has express like API).
michaelmiorover 7 years ago
How will billing work for this? It seems like I could conceivably write an entire application that just runs as a Service Worker.
djhworldover 7 years ago
Is this similar to Amazon&#x27;s Lambda@Edge?
评论 #15366940 未加载
评论 #15368134 未加载
boundlessdreamzover 7 years ago
offtopic: can cloudflare be used as a CDN for just assets? The cloudflare docs talk only about using it as CDN for an entire site.
评论 #15366405 未加载
评论 #15367157 未加载
angersockover 7 years ago
This is really cool...but <i>why</i>?
评论 #15365633 未加载
评论 #15365185 未加载
评论 #15365680 未加载
briandearover 7 years ago
Can’t you already do this with Fastly and Varnish?