Microsoft Windows Vista Community Forums - Vistaheads
Recommended Download



Welcome to the Microsoft Windows Vista Community Forums - Vistaheads, YOUR Largest Resource for Windows Vista related information.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so , join our community today!

If you have any problems with the registration process or your account login, please contact us.

Driver Scanner

What headers to respond with to get IE to send if-modified-since header?

microsoft.public.internetexplorer.general






Speedup My PC
Reply
  #1 (permalink)  
Old 03-09-2009
Daniel Smedegaard Buus
 

Posts: n/a
What headers to respond with to get IE to send if-modified-since header?
Hey

I'm feeding some image files through PHP, setting headers programatically for
caching. For FF I found that setting cache control to "public" and providing
a last modified time will make the browser provide an if-modified-since header
on subsequent requests on the same image file.

This, however, does not apply to IE (7, not sure about v6). I'm wondering
what headers I have to provide to make IE include the if-modified-since
header when it returns?

Here's an example of the headers provided with each image that is served by
my code:
------------------------
Date Mon, 09 Mar 2009 12:30:31 GMT
Server Apache/2.2.3 (Debian) mod_fastcgi/2.4.2 PHP/5.2.0-8+etch11
mod_perl/2.0.2 Perl/v5.8.8
Vary Host
X-Powered-By PHP/5.2.0-8+etch11
Cache-Control public
Last-Modified Mon, 09 Mar 2009 12:30:31 GMT
Expires 600
Content-Length 283
Keep-Alive timeout=15, max=92
Connection Keep-Alive
Content-Type image/gif
------------------------

Only some of these are specifically defined by me (Cache-Control, Last-
Modified, Expires, and Content-Type), the rest are courtesy of PHP/Apache.

TIA,
Daniel

Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-09-2009
Daniel Crichton
 

Posts: n/a
Re: What headers to respond with to get IE to send if-modified-since header?
Daniel wrote on Mon, 09 Mar 2009 13:40:31 +0100:

> Hey


> I'm feeding some image files through PHP, setting headers
> programatically for caching. For FF I found that setting cache control
> to "public" and providing a last modified time will make the browser
> provide an if-modified-since header on subsequent requests on the same
> image file.


> This, however, does not apply to IE (7, not sure about v6). I'm
> wondering what headers I have to provide to make IE include the
> if-modified-since header when it returns?


> Here's an example of the headers provided with each image that is
> served by my code:
> ------------------------
> Date Mon, 09 Mar 2009 12:30:31 GMT
> Server Apache/2.2.3 (Debian) mod_fastcgi/2.4.2
> PHP/5.2.0-8+etch11 mod_perl/2.0.2 Perl/v5.8.8
> Vary Host
> X-Powered-By PHP/5.2.0-8+etch11
> Cache-Control public
> Last-Modified Mon, 09 Mar 2009 12:30:31 GMT
> Expires 600
> Content-Length 283
> Keep-Alive timeout=15, max=92
> Connection Keep-Alive
> Content-Type image/gif ------------------------


> Only some of these are specifically defined by me (Cache-Control, Last-
> Modified, Expires, and Content-Type), the rest are courtesy of
> PHP/Apache.


> TIA,
> Daniel



You should only require a Last-Modified header, and that should cause IE
after the initial request to then send If-Modified-Since headers in
subsequent requests for the same URL. You may need to drop the Cache-Control:
public header.

I'm assuming that the above isn't the actual headers returned by your PHP as
it's missing the : between name and value and the white space shouldn't be
there.

--
Dan


Reply With Quote
  #3 (permalink)  
Old 03-09-2009
Daniel Smedegaard Buus
 

Posts: n/a
Re: What headers to respond with to get IE to send if-modified-since header?
Daniel Crichton wrote:

> Daniel wrote on Mon, 09 Mar 2009 13:40:31 +0100:
>
>> Hey

>
>> I'm feeding some image files through PHP, setting headers
>> programatically for caching. For FF I found that setting cache control
>> to "public" and providing a last modified time will make the browser
>> provide an if-modified-since header on subsequent requests on the same
>> image file.

>
>> This, however, does not apply to IE (7, not sure about v6). I'm
>> wondering what headers I have to provide to make IE include the
>> if-modified-since header when it returns?

>
>> Here's an example of the headers provided with each image that is
>> served by my code:
>> ------------------------
>> Date Mon, 09 Mar 2009 12:30:31 GMT
>> Server Apache/2.2.3 (Debian) mod_fastcgi/2.4.2
>> PHP/5.2.0-8+etch11 mod_perl/2.0.2 Perl/v5.8.8
>> Vary Host
>> X-Powered-By PHP/5.2.0-8+etch11
>> Cache-Control public
>> Last-Modified Mon, 09 Mar 2009 12:30:31 GMT
>> Expires 600
>> Content-Length 283
>> Keep-Alive timeout=15, max=92
>> Connection Keep-Alive
>> Content-Type image/gif ------------------------

>
>> Only some of these are specifically defined by me (Cache-Control, Last-
>> Modified, Expires, and Content-Type), the rest are courtesy of
>> PHP/Apache.

>
>> TIA,
>> Daniel

>
>


Hi Daniel, thanks for your reply (and for having such a pretty name, hehe)!

> You should only require a Last-Modified header, and that should cause IE


By "require" you mean I should just provide it, right? I found that to make
Firefox and Konqueror provide the if-modified-since header I had to provide
last-modified, and the cache-control: public headers.

> after the initial request to then send If-Modified-Since headers in
> subsequent requests for the same URL. You may need to drop the
> Cache-Control: public header.
>
> I'm assuming that the above isn't the actual headers returned by your PHP
> as it's missing the : between name and value and the white space shouldn't
> be there.
>


You assume right, it's copy/pasted from firebug, so it's everything that's
actually delivered to the client browser, not just what I set.

In the meantime, however, I've read some more on IE7, and it seems that
(sometimes?) it prefers to provide the if-none-match header rather than if-
modified-since. In any effect, this is the behavior I'm experiencing.

Now, if I provide an etag header, IE7 will provide an if-none-match header
on the next request, and if I use a timestamp as etag, I can determine the
age of the browser's cached item, and decide whether to send a 304 or
deliver the content. So basically I'm good there

However, I haven't gotten rid of the symptom that started me on this, which
is the fact that mouseover effects continue to flicker, since IE asks the
server if there's any new content on each mouse over or out event, even
though I believe I told it that the content I provided it with should be
good for ten minutes. Maybe you have a tip? Here are the headers I'm
providing ATM, please forgive the PHP syntax:
-----------------------------
if (represents_integer($_SERVER['HTTP_IF_NONE_MATCH']))
$retrieved_time = (int)$_SERVER['HTTP_IF_NONE_MATCH'];
else
$retrieved_time = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);

$now = time();

// We ask browsers to cache static content for 10 minutes:
if ($retrieved_time+600 < $now)
{
// We need to set a public cache control and put a "last modified" header,
otherwise we don't
// receive the "if modified since" header on subsequent re-requests:
header('ETag: '.$now);
header('Cache-Control: public');
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $now).' GMT');
header('Expires: 600');
header('Content-Type: '.$mime_type);
}
else
{
header('HTTP/1.1 304 Not Modified');
return;
}
readfile($request);
-----------------------------

Cheers,
Daniel

Reply With Quote
  #4 (permalink)  
Old 03-09-2009
Daniel Crichton
 

Posts: n/a
Re: What headers to respond with to get IE to send if-modified-since header?
Daniel wrote on Mon, 09 Mar 2009 14:30:39 +0100:

> Daniel Crichton wrote:


>> Daniel wrote on Mon, 09 Mar 2009 13:40:31 +0100:


>>> Hey


>>> I'm feeding some image files through PHP, setting headers
>>> programatically for caching. For FF I found that setting cache
>>> control to "public" and providing a last modified time will make
>>> the browser provide an if-modified-since header on subsequent
>>> requests on the same image file.


>>> This, however, does not apply to IE (7, not sure about v6). I'm
>>> wondering what headers I have to provide to make IE include the
>>> if-modified-since header when it returns?


>>> Here's an example of the headers provided with each image that is
>>> served by my code:
>>> ------------------------
>>> Date Mon, 09 Mar 2009 12:30:31 GMT
>>> Server Apache/2.2.3 (Debian) mod_fastcgi/2.4.2
>>> PHP/5.2.0-8+etch11 mod_perl/2.0.2 Perl/v5.8.8
>>> Vary Host
>>> X-Powered-By PHP/5.2.0-8+etch11
>>> Cache-Control public
>>> Last-Modified Mon, 09 Mar 2009 12:30:31 GMT
>>> Expires 600
>>> Content-Length 283
>>> Keep-Alive timeout=15, max=92
>>> Connection Keep-Alive
>>> Content-Type image/gif ------------------------


>>> Only some of these are specifically defined by me (Cache-Control,
>>> Last-
>>> Modified, Expires, and Content-Type), the rest are courtesy of
>>> PHP/Apache.


>>> TIA,
>>> Daniel




> Hi Daniel, thanks for your reply (and for having such a pretty name,
> hehe)!


>> You should only require a Last-Modified header, and that should cause
>> IE


> By "require" you mean I should just provide it, right? I found that to
> make
> Firefox and Konqueror provide the if-modified-since header I had to
> provide last-modified, and the cache-control: public headers.


>> after the initial request to then send If-Modified-Since headers in
>> subsequent requests for the same URL. You may need to drop the
>> Cache-Control: public header.


>> I'm assuming that the above isn't the actual headers returned by your
>> PHP as it's missing the : between name and value and the white space
>> shouldn't be there.



> You assume right, it's copy/pasted from firebug, so it's everything
> that's actually delivered to the client browser, not just what I set.


> In the meantime, however, I've read some more on IE7, and it seems that
> (sometimes?) it prefers to provide the if-none-match header rather than
> if-
> modified-since. In any effect, this is the behavior I'm experiencing.


> Now, if I provide an etag header, IE7 will provide an if-none-match
> header on the next request, and if I use a timestamp as etag, I can
> determine the age of the browser's cached item, and decide whether to
> send a 304 or deliver the content. So basically I'm good there


> However, I haven't gotten rid of the symptom that started me on this,
> which is the fact that mouseover effects continue to flicker, since IE
> asks the server if there's any new content on each mouse over or out
> event, even though I believe I told it that the content I provided it
> with should be good for ten minutes. Maybe you have a tip? Here are
> the headers I'm providing ATM, please forgive the PHP syntax:
> -----------------------------
> if (represents_integer($_SERVER['HTTP_IF_NONE_MATCH']))
> $retrieved_time = (int)$_SERVER['HTTP_IF_NONE_MATCH'];
> else $retrieved_time = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']);


> $now = time();


> // We ask browsers to cache static content for 10 minutes:
> if ($retrieved_time+600 < $now)
> {
> // We need to set a public cache control and put a "last modified"
> header, otherwise we don't // receive the "if modified since" header
> on subsequent re-requests:
> header('ETag: '.$now);
> header('Cache-Control: public');
> header('Last-Modified: '.gmdate('D, d M Y H:i:s', $now).' GMT');
> header('Expires: 600');
> header('Content-Type: '.$mime_type);
> }
> else {
> header('HTTP/1.1 304 Not Modified');
> return;
> }
> readfile($request);
> -----------------------------


> Cheers,
> Daniel



Check the W3C syntax for the Expires header - it's supposed to be a date,
not an integer value. In ASP you use an integer for the Response.Expires
value because the Response object internally sets the appropriate Expires
header value based on this and the current server time. At a guess this is
related to your issue - 600 may well be converted to a date by IE and
compared to the current time, and if this is treated as 600 secs since the
Windows epoch date then you're looking at a date long long ago.

--
Dan


Reply With Quote
  #5 (permalink)  
Old 03-09-2009
Daniel Smedegaard Buus
 

Posts: n/a
[SOLVED]: What headers to respond with to get IE to send if-modified-since header?
Aha!

Seems the Expires header had no effect. I now added, "max-age=600" to the
Cache-Control header, and in combination with the etag timestamp trick,
voila! IE7 caches and reuses its contents

Thanks to all who provided input

Daniel


Reply With Quote
  #6 (permalink)  
Old 03-10-2009
Daniel Smedegaard Buus
 

Posts: n/a
Re: What headers to respond with to get IE to send if-modified-since header?
Daniel Crichton wrote:

> Daniel wrote on Mon, 09 Mar 2009 14:30:39 +0100:
>> header('Expires: 600');

>
> Check the W3C syntax for the Expires header - it's supposed to be a date,
> not an integer value. In ASP you use an integer for the Response.Expires
> value because the Response object internally sets the appropriate Expires
> header value based on this and the current server time. At a guess this is
> related to your issue - 600 may well be converted to a date by IE and
> compared to the current time, and if this is treated as 600 secs since the
> Windows epoch date then you're looking at a date long long ago.
>


Funky... I could have sworn you were wrong, I went to w3.org to find the
quote to let you know so, but of course you're right. I wonder where I got
that idea? Thanks for enlightening me

Daniel

Reply With Quote
  #7 (permalink)  
Old 03-10-2009
Daniel Crichton
 

Posts: n/a
Re: What headers to respond with to get IE to send if-modified-since header?
Daniel wrote on Tue, 10 Mar 2009 09:23:03 +0100:

> Daniel Crichton wrote:


>> Daniel wrote on Mon, 09 Mar 2009 14:30:39 +0100:
>>> header('Expires: 600');


>> Check the W3C syntax for the Expires header - it's supposed to be a
>> date, not an integer value. In ASP you use an integer for the
>> Response.Expires value because the Response object internally sets
>> the appropriate Expires header value based on this and the current
>> server time. At a guess this is related to your issue - 600 may well
>> be converted to a date by IE and compared to the current time, and if
>> this is treated as 600 secs since the
>> Windows epoch date then you're looking at a date long long ago.



> Funky... I could have sworn you were wrong, I went to w3.org to find
> the quote to let you know so, but of course you're right. I wonder
> where I got that idea? Thanks for enlightening me


I went to W3C in order to find the syntax to check I was right before
posting

--
Dan


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
windows vista on hp computer will not allow me to respond or send jen microsoft.public.windows.vista.mail 5 11-11-2008 21:55
Page last modified Gren microsoft.public.internetexplorer.general 8 11-06-2008 10:49
IE 7.0 modified by AT&T Xenon microsoft.public.internetexplorer.general 5 08-02-2008 05:26
BCC, how to I add it to header Hella microsoft.public.windows.vista.mail 4 07-05-2008 01:26
"Date Modified" Column Header Disappears SoxFanInVA microsoft.public.windows.vista.general 4 04-27-2007 21:42




All times are GMT +1. The time now is 19:15.




Driver Scanner - Free Scan Now

Vistaheads.com is part of the Heads Network. See also XPHeads.com , Win7Heads.com and Win8Heads.com.


Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.6.0 RC 2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120