From: Marc J. Cawood on
We have a web application running over a WAN on IIS6. Some of our
locations have large latency which results in certain pages, with many
scripts and images, taking up to 20 seconds to load. If we analyse the
traffic with Fiddler we see that 90% of the requests (i.e. 90
requests) are for scripts, images, xsl and CSS which never change.

However the browser (IE7) stubbornly insists on requesting them each
time and sending a "If-Modified-Since" header to which the server
replies with a 304. Sadly this 304 is not accompanied by a Cache-
Control header. However we have set "Cache-Control: max-age=2419200"
on all these resources in IIS and, when the resource is first
requested (i.e. browser cache is cleared), a 200 is sent with the
"Cache-Control" and "Expires" headers correct.

Why does the browser ignore the Expires header initially and always re-
request and confirm?
Is there any way to avoid this needless traffic via IIS or via IE?
From: Chris M on
On 20/04/2010 11:50, Marc J. Cawood wrote:
> We have a web application running over a WAN on IIS6. Some of our
> locations have large latency which results in certain pages, with many
> scripts and images, taking up to 20 seconds to load. If we analyse the
> traffic with Fiddler we see that 90% of the requests (i.e. 90
> requests) are for scripts, images, xsl and CSS which never change.
>
> However the browser (IE7) stubbornly insists on requesting them each
> time and sending a "If-Modified-Since" header to which the server
> replies with a 304. Sadly this 304 is not accompanied by a Cache-
> Control header. However we have set "Cache-Control: max-age=2419200"
> on all these resources in IIS and, when the resource is first
> requested (i.e. browser cache is cleared), a 200 is sent with the
> "Cache-Control" and "Expires" headers correct.
>
> Why does the browser ignore the Expires header initially and always re-
> request and confirm?
> Is there any way to avoid this needless traffic via IIS or via IE?

Check that IE is not set to check for updated versions of the content on
every visit to a page.

When IE is set to check automatically, it will only do a conditional GET
(i.e. a GET with an if-modified-since) if it deems the cached copy to be
stale (in other words, it has been requested before its max-age has been
reached or it hasn't passed the Expires header date/time).

If IE has been set to check for updated content on every visit, it will
do a conditional GET regardless of whether the cached copy is stale or not.

This might be useful:

http://msdn.microsoft.com/en-us/library/bb250442.aspx


--
Chris M.
From: Robert Aldwinckle on

"Marc J. Cawood" <cawoodm(a)gmail.com> wrote in message
news:62f4772d-fa16-47e5-bfdb-5f693e22fdc3(a)w3g2000vbw.googlegroups.com...

> Why does the browser ignore the Expires header initially and always re-
> request and confirm?

> Is there any way to avoid this needless traffic via IIS or via IE?


Yes. Use the Never cache-checking option. Otherwise see if the
Every time I start... option works better for you. AFAICS Automatically
works about the same as Every time I visit... which is probably what you
are seeing. However, another option supposedly would be using the IE
cache-checking limits on your web site (specific to IE only). I used to
post a link about that which IIRC had a diagram in it about a green zone to
explain how it would work but I can't find either now. You may get a more
informed answer from a forum for web development about that last option.


HTH

Robert Aldwinckle
---

From: Marc J. Cawood on
> If IE has been set to check for updated content on every visit, it will
> do a conditional GET regardless of whether the cached copy is stale or not.

I'm a bit wary of saying "never" - will IE still update expired
content?

> This might be useful:
> http://msdn.microsoft.com/en-us/library/bb250442.aspx

This article seems to indicate that a clever developer can avoid
needless 304s.
> > However, even an HTTP/304 requires a full roundtrip to the
> > remote Web server; by carefully setting response headers,
> > a Web application developer can eliminate the need to issue even
> > conditional requests.
> > ...
> > As you can see, we've improved performance by adding an Expires
> > header, since no conditional HTTP request is made during Session #2.

So I just need to add an "Expires" header on my content... strange
that
the "Cache-Control: max-age=1209600" doesn't cut it?!?

From: Marc J. Cawood on
I checked my headers again in Fiddler and I had no "Expires" header in
the response. This is strange because in IIS6 I have "Enable Content
Expiration" set to "Expire after 200 days". When I now set IIS to a
fixed date in the future it sends the "Expires" header! IIS Bug??

It's working nicely now without superfluous 304s - at least in IE8
(Windows7) - thanks.