cweiske
cweiske

Reputation: 31147

Common HTTP header to disable cache in server-sided web application

I have a php-based web application that does some internal caching of content fetched from another CMS. When editors modify content in the CMS and then reload the web application's website, it will still deliver the cached content. (The CMS does not know of the web application, so there is no automatic cache invalidation possible.)

Now I would like to add a way for editors to use the web application without caching. This could be done with an URL GET parameter, as TYPO3 does it with no_cache=1. This requires manual intervention.

It would be much cooler if there was a browser extension that could be used to toggle caching on/off, and which would just inject an HTTP header in the GET request. The web application would react to that header and internally disable caching.

So my question: Is such a HTTP header used in the wild? How is it called?

Upvotes: 0

Views: 2173

Answers (1)

Kevin Christopher Henry
Kevin Christopher Henry

Reputation: 49092

Yes, there is such a header: Cache-Control.

You might be familiar with this as a response header, but a client can also send it as a request header. In your case, you'd set Cache-Control: no-cache on the request. From RFC 7234:

The no-cache request directive indicates that a cache MUST NOT use a stored response to satisfy the request without successful validation on the origin server.

Upvotes: 1

Related Questions