Setting Expire Header for PHP pages

Setting up expire header for PHP pages


If we set expire header for a page, javascript files, style sheets or images, we can reduce the number of requests from client and also we can increase the page loading time. For apache server we can setup expire header using .htaccess file. In many cases we are displaying images via PHP. need to set up expire header for our page. Using the below code


header("Content-type: image/gif");
$expires = 60*60*24*30;//second*minute*hour*days
header("Pragma: public");
header("Cache-Control: maxage=".$expires);
header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT');


Related Topic JSP Interview Questions & Answers
What is Redirection and their Types
Set up expire header in apache using htaccess file
What are all the SEO Factors to be Considered While Optimizing a Website
How to Configure Apache web Server Document Root Directive

nScraps.com 2011   Privacy Policy  Terms of Service  Feedback