Web Servers on Unix and Linux - HTML -vs- image cache question

This is Interesting: Free IT Magazines  
Home > Archive > Web Servers on Unix and Linux > February 2005 > HTML -vs- image cache question





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author HTML -vs- image cache question
fochie

2005-02-08, 2:51 am

Greetings,

Not sure if this the "right" place to ask ...

I would like to be able to serve up HTML pages, that contain 100's of
links to images on my server and have the images ALWAYS cached by the
client/proxy server/etc. but NEVER the HTML page itself.

My HTMLs are updated daily to contain new image links along with
potentially many of the old links remaining. New links added always use
new image filenames and the names never reused. The old images are
removed from the server when the HTML is updated.

The problem I'm seeing is that without any cache mechanism the HTML
page itself is being cached, which then contains links to non existant
images on my server.

If I include HTTP expire headers to effectively never cache the HTML
page, I think I then loose the performance gain of having the images
themselves remain in cache.

Is there a way to handle both of these cases where I want to have
images served from cache whenever possible yet the HTML that contains
the links to them never cached ?

Any insight/advice/assistance is most appreciated.

Thanks !

Envir -
Dedicated Linux RHEL3 Intel server
Apache

Nick Kew

2005-02-08, 7:56 am

fochie wrote:

> Greetings,
>
> Not sure if this the "right" place to ask ...
>
> I would like to be able to serve up HTML pages, that contain 100's of
> links to images on my server and have the images ALWAYS cached by the
> client/proxy server/etc. but NEVER the HTML page itself.


No chance. You can't force or prevent cacheing unless you control
the Client. The best you can do is to set headers that agents will
honour *unless* configured to do otherwise (e.g. browser preferences).

> My HTMLs are updated daily to contain new image links along with
> potentially many of the old links remaining. New links added always use
> new image filenames and the names never reused. The old images are
> removed from the server when the HTML is updated.


OK, what you want is default behaviour in Apache and (AFAIK) other
webservers, provided you don't mess with it. Look up the HTTP
If-Modified-Since header and 304 response for how it works.

--
Nick Kew
fochie

2005-02-08, 5:49 pm

Thanks Nick,

After a little more reading I'm note sure why the solution below
wouldn't solve my problem -

Again, the goal as I see it is to have web cache proxies, and client
browsers, respect the following -

NEVER cache my HTML files
ALWAYS cache my image files when possible

Since we already recompiled our Apache server to include "mod_expires",
I think adding the following initial directives to our Apache config
may accomplish what I'm after -

ExpiresActive on
ExpiresByType text/html "access plus 0 hours"
ExpiresByType image/jpeg "access plus 10 days"
ExpiresByType image/gif "access plus 2 days"
ExpiresDefault "access plus 2 days"

I would look at finer grained cache control via .htaccess and HTTP
headers after judging the effects of the change described above.

Anyone see any problems with this approach ?

Thanks !!

Tim

2005-02-10, 2:47 am

On 8 Feb 2005 11:45:35 -0800,
"fochie" <sborruso@austin.rr.com> posted:

> ExpiresByType text/html "access plus 0 hours"


Make that longer. There's nothing more annoying that navigating through a
site and having to slowly reload a page you just looked at a few minutes
ago, because you have to go back to it to navigate to something else. It's
because of this daft sort of thing that some caches ignore instructions
from servers.

At the very least make it ten minutes. That gives navigation time for most
people, and keeps things current enough for rapidly changing sites. Though
I'd make it at least an hour. It's extremely annoying to try and go back
to read something that caught your interest, only to find that it's gone.

--
If you insist on e-mailing me, use the reply-to address (it's real but
temporary). But please reply to the group, like you're supposed to.

This message was sent without a virus, please delete some files yourself.
fochie

2005-02-10, 5:52 pm


Hadn't thought of that annoying consequence when forcing a callback for
an HTML each time. I'm sure we can live with a 1 hr latency setting.

Thanks for the advice Tim !

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com