Set no-cache no-store on the server

Set no-cache no-store on the server

DomJM
Shopify Partner
3 0 0

I have written several scripts and tested them in the Preview builds. When those changes are published the to the live theme, I noticed the code breaking and the scripts not running in the network tab. This seems to be due to the Preview Builds having `no-cache no-store` set to server cache, while Published builds have caching on by default. I've attempted to alter the meta-tag headers, implement cache-busting etc. all to no avail.

I'm looking for advice on how to alter the server cache settings without the use of a full-stack framework like Hydrogen or Remix, and/or a method of refactoring to get these scripts to run on cache'd pages somehow.

Replies 3 (3)

Benji4
Shopify Partner
1 0 1

@DomJM Did you find an answer to your question?

 

I'm using Liquid and want to prefetch products in the viewport on a product list page. I'm using:

 

<link rel="prefetch" href="{{ product.url }}" as="document">
 

 The cache-control header is set to no-cache, no-store are also causing issues for me.

 

Do you know if caching prefetch requests works in production and did you ever find a way to have it work on local dev and preview builds?

DomJM
Shopify Partner
3 0 0

I never found a way to successfully break the prod cache. It seems to be a immutable feature; it kind of just does what it does. Unsure about the possibility if you can cache prefetch in prod or other build steps. To break the cache I had to hard reload the page upon navigation using .reload() because I could not toggle the cache settings.

DomJM
Shopify Partner
3 0 0

Wish you luck @Benji4, lmk if you find a solution!