It seems more and more hosting providers are setting up Varnish Cache to speed up websites.
This is good, except by default Varnish seems to gobble up and cache everything (even if the PHP script sends no-cache headers). So I’m getting an increasing number of people having issues with my standalone scripts.
The two most comment problems are:
Help, I cannot login! I enter my login details to your script and it just takes me back to the login page, no errors or messages or anything.
Help! The app is automatically logged in from any computer and is showing my information to everyone!
The quickest way to see if Varnish is the problem: Open Chrome, hit F12, click “Network” tab, type in address for the script, then click on the first entry in “Network” and look for the response header “Varnish: HIT”.
If you see Varnish HIT it means you’re getting a cached version of your script.
The quickest fix is to get the hosting provider to disable varnish for that particular domain. Then ask the hosting provider to setup Varnish correctly, so that it ignores no-cache headers.
It’s still really weird because varnish (by default) shouldn’t cache anything with a cookie. Maybe these hosting providers are just setting it up all wrong.
Anywho hope that helps someone.