3

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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Alright, thanks! Is there any reason for doing this: header('Cache-Control: no-cache, must-revalidate'); header('Expires: '.date('r', time()+(86400*365)); (ellislab.com/forums/viewthread/190001)?
@seberik - my guess is that the + /plus/ is a typo and was supposed to be a - /minus/.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.