Santosh Nagarajan - 2008-12-06 17:01:32
Hi All,
I have a specific requirement of setting http cache headers for images and css files through PHP.
I have a single php file as follows:
-------index.php------------------------------------------------------------------
<?php
header('Cache-Control: no-cache');
print('<?xml version="1.0" encoding="ISO-8859-1"?>'."\n");
?>
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Cache Test</title>
<link type="text/css" rel="stylesheet" href="mycss.css"/>
</head>
<body>
<p>This page contains the header 'Cache-Control: no-cache'<br/>
<?php echo date("F j, Y, g:i:s a"); ?><br/>
</body>
</html>
-----end of index.php--------------------------------------------------------------------
The header set in the page is for the markup content. Whereas I need to set same http headers for image and css file. When I checked this page using a protocol analyser I found that image and the css file are not having cache headers. Only the "index.php" has the specified header.
How to set same headers using PHP for the image and css ?
I have Apache/v1.3.27 on Linux with PHP 4.4.8
-Santosh