Are static files counted in Service Workers requests?

If I’m using edge caching for HTML pages for a WP site, will static files pass-through service workers and are counted as requests?

The route that I have to put will be like my-site.com/*

Otherwise, the free plan of Service Workers allows 100,000 requests per day. If a website has 100 requests in a page (including HTML, CSS, JS, Images etc), that would make only 1k page views a day.

Even if I upgrade to the “Unlimited” plan, that would make only 3 times that of the free plan (~3k page views a day, assuming 100 requests in a page).

If static files are counted, any way to exclude them?

Yes, they are counted. You can create a disabled route, that will exclude it from running the worker.

ok, Thanks for the quick response.

So if the images are inside “wp-uploads” folder, I just have to create a route like “my-site.com/wp-uploads/*” and set “None” for the worker. Right?

Also, how to set the priority for routes? Basically now I’ve two routes that might create conflicts, like “my-site.com/" and "my-site.com/wp-uploads/

Exactly. The most specific route will take precedence.

Ok. Got it. One more doubt, how does worker routes aligns with page rules?

For example I’ve assigned a worker to “example.com/" and I’ve set “Cache Everything” using Page Rules for the sample route, "example.com/”. Which one will work in this case (and run first)? Or ‘Page Rule’ are completely ignored?

Page rules (redirects, for example) run before Workers, but the cache is after the worker. A Worker will always run when a request is received, regardless of Page Rules and cache settings.

Awesome. Thanks a lot

1 Like