PHP Caching Headers

person shubham sharmafolder_openPHPlocal_offer, access_time August 8, 2017

Make sure a page is never cached with PHP

To make sure the page is never cached (or whatever other dynamic content generated from PHP such as images, RSS files etc) add the following to the start of your script:

To set the amount of time to cache

If instead you want the output from the script to be cached for a certain amount of time, set the expires header to a time in the future. For example, to make it so the browser will cache the output for 1 hour do this:

The Cache-Control header requires the number of seconds to cache the file so in this example it’s 3600 because 60 seconds x 60 minutes = 3600.

warningComments are closed.