Advertisement
locvfx

Cache control in PHP - and how to test Varnish cache

Sep 16th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.51 KB | None | 0 0
  1. <?php
  2. //http://stackoverflow.com/questions/4480304/how-to-set-http-headers-for-cache-control
  3.  
  4.  
  5.   //set headers to NOT cache a page
  6.   header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
  7.   header("Pragma: no-cache"); //HTTP 1.0
  8.   header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  9.  
  10.   //or, if you DO want a file to cache, use:
  11.   header("Cache-Control: max-age=2592000"); //30days (60sec * 60min * 24hours * 30days)
  12.  
  13.   //Check Varnish cache
  14.     //http://www.isvarnishworking.com/
  15. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement