I need a hand to know how I can handle route rules with a Nuxt 3 project with enable and disable cache.
The point is, below the examples:
/c-[category-page-slug] → cache it
/c-[category-page-slug]?queryparam1=value1&queryparam2=value2 → not cached
N.B Our site were deployed on Netlify.
I tried to add some rules inside public/_redirects file like below:
/c-/* utm_id=:utm_id utm_source=:utm_source utm_medium=:utm_medium utm_campaign=:utm_campaign /.netlify/functions 200
/c-/* /.netlify/builders/server 200
Hiya @AtomsDevs and sorry to be slow to get back to you!
Since you posted in the on-demand builders category I assume you are using builder functions that have URL’s like https://site.com/.netlify/builders/c-category-page-slug ? Those are cached by default until next deploy unless you set a revalidate timeout.
It explains what the intentions are now around caching, but TL;DR if you aren’t using builder functions, then you could use the specific advice in there which is better stated than any made-up example I could provide would be. You’ll see that you can change the caching directives right in your function code
Hi @fool, thank you for your kind response but I still have some doubts about the whole implementations.
You are saying that those functions are cached by default, but not if the page contains query params.
I read the article you linked but didn’t get if through a one these Cache-Control, CDN-Cache-Control or Netlify-CDN-Cache-Control I am able to cache also the query params.
For reference I’m talking about this discussion. Unfortunately I can’t solve the problem going through the workaround linked by Luke.
You are able to cache any response on our CDN if you set one of those caching headers.
We don’t cache ones with query params, since we presume they will include parameters like userid=X which will not be “generic in their response”, by default.