Like us on Facebook and stand a chance to win pen drives!

Prevent HTTP Cache with PHP

HTTP Cache
HTTP Cache
HTTP Cache can be troublesome during development in some occasions specially in developing and testing web services, testing endpoints. We can use PHP headers to prevent and disable HTTP cache. 

header("Content-Type: application/json");
header("Expires: 0");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");

 Other than the above, there are other techniques of prevent  browser caching.


0 comments:

Copyright © 2012 The Code Junction.