Are workers are called for each assets files?

Hello,
We haven’t yet tested Workers, but before that, we would like to known when this workers is called please?
One time for the page requested, or on every contents (html, js, css, images … ) from the page ?
Because we don’t want to be charged on Wokers for the assets, and only 1 time per .html page access.
Regards

1 Like

Every asset is billed against KV pricing, see here:

As Workers Sites use Workers and Workers KV, their usage goes into account towards your monthly bill.

KV Pricing:

There really should be a calculator for this. And preferably an asset counter shown in Wrangler.

1 Like

Thanks for the answer @thomas4 … It seems to be really bad in our case, this increase our Serverless cost by 73x on some page, and totally useless because we already use the free CF CDN.

May be there is a solution, if the assets are hosted on another domain ?
Website on domain1.com, the worker return the HTML content, and inside the images have src attributes to domain2.com ?
The CF workes/KV price should only be called one time per page and ignore all assets, right ?

Correct, but also a different path would work, you can disable Workers per path (or enable per path). If all assets fall in the /assets/ path disable Workers for those.

3 Likes

Thanks @matteo ! I was said domain2.com because we would like to use the free CDN plan of CF for assets.
But, may be your solution to ignore domain1.com/assets/ can still permit to theses assets to be in CF cache with the CF CDN free plan ?

Of course, you are simply not running the Worker on that path.

Read through the Workers docs for routes (maybe even the rest, but start here):

https://developers.cloudflare.com/workers/about/routes/

2 Likes

Thanks a lot @matteo !