Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP remove HTTP header

Something, I think Apache, adds these HTTP headers to all responses generated by PHP scripts:

Expires:   Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control:  no-store, no-cache, must-revalidate, post-check=0, pre-check=0

This works ok for actual dynamic pages, but I have some page that, while generated by PHP, are mostly static, and I want the browser to cache them.

Is there a way in PHP to remove those headers from the response, and thus activate the browser's default caching rules, or if not, is there any value I can set them to that's equivalent with them being absent?

I would prefer not to set my own values, because I want the browser to use the same caching rules as for static resources that are served by Apache itself (without using mod_cache).

like image 834
Bart van Heukelom Avatar asked Dec 21 '09 00:12

Bart van Heukelom


1 Answers

For those particular files you could add header() calls that set those headers differently. ie. header("Expires: " . $currentDatePlus10);

header("Cache-Control: max-age=3600, must-revalidate")
like image 94
Myles Avatar answered Oct 02 '22 16:10

Myles