PHP Classes
elePHPant
Icontem

How to set cache header for each object of the php/xhtml page?

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Top level forums  >  PHP Specialists  >  General  >  How to set cache header for each...  
Subject:How to set cache header for each...
Summary:How to set cache header for each object of the php/xhtml page?
Messages:3
Author:Santosh Nagarajan
Date:2008-12-06 11:08:17
Update:2008-12-08 20:27:49
 

  1. How to set cache header for each...   Reply   Report abuse  
Picture of Santosh Nagarajan 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

There are 2 replies in this thread, which are not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.