If you have caches of some kind in your backend code; you may probably want to clear or bypass them at some point instead of waiting out the TTL. Here’s a convenient solution that we’ve used for a while in our Symfony projects. It’s applicable to any HTTP backend though.

Basically we just check the Cache-Control header; when it’s set to no-cache the browser is probably either doing a hard reload, or it has the cache disabled through its developer tools.

The best thing about it is non-technical users can use it too (editors or any kind of superusers for example); just teach them to do a hard reload, and they can get fresh uncached content at will.

The following example is a Symfony service that gets content from a cache unless the Cache-Control: no-cache header is sent. Pretty basic.

Depending on the kind of things you cache; you may want to limit this to requests from your own network, or logged in users with certain privileges.