Reputation: 415
The following headers seem to be recommended using when outputing JSON:
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
What is the purpose of the Expires header when Cache-control is set to no-cache, must-revalidate?
Upvotes: 3
Views: 5909
Reputation: 1
The first two headers prevent the browser from caching the response (a problem with IE and GET requests) and the third sets the correct MIME type for JSON.
Upvotes: 0
Reputation: 1949
This resolves some browser and caching proxies issues.
It seems like there are some of these that do not understand some headers and/or are configured not to, so it is just a workaround trying to be compatible with a little more of the end users' browser and caching proxies in the middle.
Upvotes: 2