evolution / wordpress

Rapidly create, develop, & deploy WordPress across multiple environments.
MIT License
200 stars 18 forks source link

Restarting varnish did NOT clear cached script #168

Closed EvanK closed 7 years ago

EvanK commented 7 years ago

Witnessed an issue where, after a deployment and repeated restarts of both apache and varnish services, a particular minified javascript file was still returning a cached version from pre-deployment.

We verified the file on the filesystem was up to date, and that varnish was restarted (by hand even!), but continued to return a stale version of the file in question.

Finally resolved it by ssh-ing into the server and purging the url specifically:

curl -vvv \
--header 'Host: feature-branch.staging.example.org' \
-X PURGE \
http://localhost/wp-content/themes/customtheme2014/assets/dist/footer.min.js

It worries me that restarting everything short of the entire damned server failed to purge a stale file, and I'll have to investigate further a possible root cause. In the meantime, and for easier purging, we may want to add a capistrano task for purging a given url (and on a given hostname)

EvanK commented 7 years ago

For reference, to reboot the entire server when nothing else works: sudo reboot now in an ssh term

EvanK commented 7 years ago

According to the varnish mailing lists, a service restart should entirely clear existing cache storage...but we're seeing evidence that it doesn't necessarily.

It could be that the storage file is being reloaded and re-using existing cache objects, rather than being zeroed and recreated.

One alternative may be to add a cap task for forcing purge/ban of all cache objects (possibly followed by another service restart): sudo varnishadm -S /etc/varnish/secret "ban.url . "

Another alternative would be to force ban of cache objects matching a given url and/or extension:

EvanK commented 7 years ago

I've added a :cache:clear cap task for the express purpose of force-clearing cache objects, either wholesale by domain or specifically by url:

image