How to disable Varnish Cache from within a PHP script? -


i distribute php script , lot of people having trouble varnish cache on shared hosting accounts.

this code @ top of php script. still "varnish: hit" in response headers (and script doesn't work correctly).

header('pragma: no-cache'); header('cache-control: private, no-cache, no-store, max-age=0, must-revalidate, proxy-revalidate'); header('expires: tue, 04 sep 2012 05:32:29 gmt'); 

one hosting provider said impossible disable varnish within php script, setting cache headers above. seems .. .. silly? seems match experience.

so there way disable/skip varnish within php? or varnish (by default) ignore these cache headers set php?


thanks jens-andré koch - i'll include varnish instructions along php script make ignore no-cache responses:

sub vcl_fetch {         if (beresp.http.cache-control ~ "(no-cache|private)" ||             beresp.http.pragma ~ "no-cache") {                 set beresp.ttl = 0s;         } } 

you have configure varnish avoid caching page. modify vcl detect headers... specify own header turn caching off file or add statically non-cached config.

https://www.varnish-software.com/static/book/build/exercises/complete-avoid_caching_a_page.html?highlight=headers


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -