Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Response headers

Tags:

json

php

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?

like image 665
seberik Avatar asked Apr 21 '26 06:04

seberik


1 Answers

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.

like image 54
blue Avatar answered Apr 22 '26 21:04

blue