Is there a way to specify NO cache for a specific resource ? (ws.js registration for a PWA)

Hi,

in my code I’m adding this:
if (‘serviceWorker’ in navigator) { navigator.serviceWorker.register(’/ws.js’); }

but when I change it in the server and reload the page, the browser get the cloudflare cached version

it’s nice for every other .js, but not for this specific one.

In page rules I don’t see how I can do that for 1 particular resource.

can I add a query string “telling” cloudflare NOT to cache it ???
like is there a .js?caching=nocache or something similar ???

note : I cannot put this in a subdomain because it’s a service worker and ABSOLUTELY needs to be in the root folder of the main domain for the scope and everything for PWA (progressive web app)

1 Like

If that particular resource is a specific URL, you can make that the Match (example.com/resources/ws.js), and then Cache Level of Bypass.

3 Likes

Nice it works :wink:

1 Like

I realized I needed this one! Probably all PWAs. The Free plan has 3 page rules. Here’s a screenshot for others:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.