You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by dave selby <da...@googlemail.com> on 2008/09/11 22:28:15 UTC

[users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Is there a way for me to turn off if-modified-since so the client
browser will ALWAYS use its locally cached document

ie from the definition below Apache always returns a 304 reply ?

"If-Modified-Since: date
This request header is used with GET method to make it conditional: if
the requested document has not changed since the time specified in
this field the document will not be sent, but instead a Not Modified
304 reply. "

I realise this is unusual but in my case very needed :)

Many thanks

Dave






-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by Manik Taneja <mt...@movik.net>.
dave selby wrote:
> 2008/9/12 André Warnier <aw...@ice-sa.com>:
>   
>> Manik Taneja wrote:
>>     
>>> Nope, there is no way you can prevent the client from sending you an IMS
>>> request.
>>>       
>> The above is correct, but if I understand the OP question correctly, the
>> basic issue is to make sure that the client does not re-use a cached page,
>> but always retrieves the latest page from the server.
>>     
>
> Sorry, its me not explaining myself very clearly. Its the opposite.
>
> If you look at kmotion v1 you will see why ....
> http://code.google.com/p/kmotion/wiki/ScreenShots its more like an
> application than a conventional web page. I have a directory that is
> constantly updated with new images, because the directory is
> constantly having its 'last modified' date changed apache keeps
> resending images that do not need to be sent. And these are not small
> files.
>   
You could try by setting the Age and Expires header in the response to a 
largish value. However, that will still not guarantee clients not 
sending a freshness check to the server.

> None of the images are ever changed, they each have a unique name and
> are deleted by background daemons so once loaded I really don't want
> to have to reload it again if for arguments sake I need to flip back
> to the last frame.
>
> kmotion v1 is alive and well but I am writting v2 & am trying to
> improve responsiveness etc.
>
> Sorry for the long explanation - but I hope this explains my problem.
>
>   
>> There is a whole array of things one can do on the server side, to at least
>> try to achieve this. I don't recall all the specifics, but look for instance
>> at HTTP headers such as "Cache-control".
>> See here
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
>> section 14.9
>>
>> The general idea is : the server, by a combination of HTTP headers sent
>> along with the documents, and tags in the documents themselves, should be
>> able to tell the client whether this page can, or cannot, be cached and
>> re-used.
>> And according to the HTTP specifications, the client (and any intermediate
>> proxies) should obey these instructions.
>>
>> Now whether they always actually do, is anothet issue.
>> (But in the practice I have noticed that they generally do).
>>
>> To modify the HTTP headers that Apache sends along with documents, you could
>> use something like this :
>> http://httpd.apache.org/docs/2.2/mod/mod_headers.html
>> or mod_perl handlers.
>>
>>
>> André
>>
>> ---------------------------------------------------------------------
>> The official User-To-User support forum of the Apache HTTP Server Project.
>> See <URL:http://httpd.apache.org/userslist.html> for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>>     
>
>
>
>   


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
> André Warnier wrote:
> 3d try :

supposes mod_setenvif, mod_rewrite, mod_header

> 
  RewriteEngine on
  RewriteLog /var/log/apache2/mysite/rewrite.log
  RewriteLogLevel 9   (so we see what's happening)

  <Location /thelocation>

  # 1) check if there is a trigger header and set a var if so
  SetEnvIf If-modified-since (.*) wants_cache=1
  # 2) but unset the var if it's *not* an image request
  # (to let Apache handle that normally)
  SetEnvIf Request_URI !\.(gif|png|jpg)$ !wants_cache
  # 3) next, the condition is that the variable wants_cache is set
  RewriteCond %{ENV:wants_cache} ^1$
  # 4) and if so, we send a "not modified" response
  RewriteRule ^.*$ - [R=304,L]

  </Location>
> 

Worth a try ?
(I'm learning mod_rewrite as I go along, I hope)

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
2d try :

RewriteEngine on
RewriteLog /var/log/apache2/mysite/rewrite.log
RewriteLogLevel 9   (so we see what's happening)

<Location /thelocation>
# 1) check if there is a trigger header and set a var if so
SetEnvIf If-modified-since (.*) wants_cache=1
# but unset the var if it's *not* an image request
# (to let Apache handle that normally)
SetEnvIf Request_URI !\.(gif|png|jpg)$ !wants_cache
# next, the condition is that the variable wants_cache is set
RewriteCond %{ENV:wants_cache} ^1$
# and if so, we re-direct this to /notmod
RewriteRule ^.*$ /notmod [L]
...
</Location>
<Location /notmod>
# this one should always send a "not modified" answer
...
</Location>

and now I'm stuck again, because I still don't know how to send back 
only headers, not a body.
The general idea would be to redirect the calls to the original 
directory, which wanted images, to some generic URL which always sends 
back a "not modified" answer.
It would be easier with mod_perl, but I'm trying to do this strictly 
with Apache modules.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by dave selby <da...@googlemail.com>.
2008/9/12 André Warnier <aw...@ice-sa.com>:
> dave selby wrote:
>>
>> 2008/9/12 André Warnier <aw...@ice-sa.com>:
>>>
>>> Manik Taneja wrote:
>>>>
>>>> Nope, there is no way you can prevent the client from sending you an IMS
>>>> request.
>>>
>>> The above is correct, but if I understand the OP question correctly, the
>>> basic issue is to make sure that the client does not re-use a cached
>>> page,
>>> but always retrieves the latest page from the server.
>>
>> Sorry, its me not explaining myself very clearly. Its the opposite.
>>
> Yes, I apologise, I saw that later.
>
> First, I don't know if the behaviour that you describe for Apache (to
> consider that the file is modified if its directry is) is normal or not.
> Maybe someone else can comment on that.

Yep I need to pin this down. I use an alias to access the images dbase
and it appears to be the 'images_dbase' dir
modified time that is tripping apache into thinking the image file has
been modified.

Alias /images_dbase/ /home/dave/kmotion2/images_dbase/

Can anyone say definitively how apache knows if a file has been
modified, I know its not just the file modification time,
does it check every dir's modification time in the entire path ?


> But assuming for the time being that this is really what happens, then a
> possible solution might be along these lines :
>
> You can still not stop the browser from sending its request with an
> "If-modified-since" header.  But maybe on the server you can just pre-empt
> Apache's own check, and immediately return a "not modified" to the browser.

OK

> In a <Location> or <Directory> section (depending on what exactly you want
> to submit to this behaviour), you would need to
> - have something that examines the incoming request headers, and detect if
> there is an "If-modified-since" header (and maybe, to be sure, if the
> request is for one of the image files).
> - if it is so, "force" a response "not modified" to the browser, so that it
> will use its cached version.
>
> I think mod_rewrite should allow you to do that.

Interesting ...

> But you must be somewhat careful, so that you do indeed not end up blindly
> sending "not modified" headers for everything on your server, just for
> specifically these files that you don't want always resent.
>
> Also, there may be more to send back than just a "304 Not Modified" status
> line.
>
> I am interested to work this out with you, because I just started myself
> this very morning to look at the mod_rewrite module, and I'm curious if this
> is something it can do.
> The mod_rewrite capabilities (and docs) are somewhat daunting though, so if
> a specialist could jump it to offer help, it would not be refused.

I have previously looked at mod_rewrite myself, it game me the
impression of powerful but as you say daunting :) As it ended up I did
not need it.

>
> Here is an example of a request and a response, which I just captured with
> the Firefox add-on "Live Http Headers" :
>
> GET /docs/2.2/images/mod_rewrite_fig2.gif HTTP/1.1
> Host: httpd.apache.org
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.15)
> Gecko/20080623 Firefox/2.0.0.15
> Accept: image/png,*/*;q=0.5
> Accept-Language: en-gb,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Referer: http://httpd.apache.org/docs/2.2/rewrite/rewrite_intro.html
> If-Modified-Since: Tue, 20 Sep 2005 11:00:07 GMT
> If-None-Match: "3c12a-9f9-40131f6791bc0"
> Cache-Control: max-age=0
>
> HTTP/1.x 304 Not Modified
> Date: Fri, 12 Sep 2008 09:33:28 GMT
> Server: Apache/2.2.9 (Unix)
> Connection: Keep-Alive
> Keep-Alive: timeout=5, max=96
> Etag: "3c12a-9f9-40131f6791bc0"
>
>
> From the look of it, it would seem that none of the lines following the
> initial status line are really essential.

I agree ... though you are more fluent in Apache / HTTP than me ... I
see where you are going with this and it might just work
although I am now thinking of a more daemon oriented approach so
restructure 'images_dbase' to avoid this issue.

The problem is, and I found this when I released kmotion v1, if you do
__ANYTHING__ a bit unusual or non standard the application
ends up breaking on this server version, on this hardware etc etc so I
am trying to keep away from unusual.

> The only one I'm not sure of, is the "Etag", which seems to correspond to
> the request header "If-none-match".
>
> Let's say my first try would be like
>
> RewriteEngine on
> RewriteLog /var/log/apache2/mysite/rewrite.log
> RewriteLogLevel 9   (so we see what's happening)
>
> <Location /thelocation>
> RewriteRule [^/]+\.(gif|jpeg|png)$ - [L]
> ...
> </Location>
>
> And now I'm stuck, because I don't know yet how to tell mod_rewrite to send
> a response with some headers, but no body ..
>
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
dave selby wrote:
> 2008/9/12 André Warnier <aw...@ice-sa.com>:
>> Manik Taneja wrote:
>>> Nope, there is no way you can prevent the client from sending you an IMS
>>> request.
>> The above is correct, but if I understand the OP question correctly, the
>> basic issue is to make sure that the client does not re-use a cached page,
>> but always retrieves the latest page from the server.
> 
> Sorry, its me not explaining myself very clearly. Its the opposite.
> 
Yes, I apologise, I saw that later.

First, I don't know if the behaviour that you describe for Apache (to 
consider that the file is modified if its directry is) is normal or not.
Maybe someone else can comment on that.
But assuming for the time being that this is really what happens, then a 
possible solution might be along these lines :

You can still not stop the browser from sending its request with an 
"If-modified-since" header.  But maybe on the server you can just 
pre-empt Apache's own check, and immediately return a "not modified" to 
the browser.

In a <Location> or <Directory> section (depending on what exactly you 
want to submit to this behaviour), you would need to
- have something that examines the incoming request headers, and detect 
if there is an "If-modified-since" header (and maybe, to be sure, if the 
request is for one of the image files).
- if it is so, "force" a response "not modified" to the browser, so that 
it will use its cached version.

I think mod_rewrite should allow you to do that.

But you must be somewhat careful, so that you do indeed not end up 
blindly sending "not modified" headers for everything on your server, 
just for specifically these files that you don't want always resent.

Also, there may be more to send back than just a "304 Not Modified" 
status line.

I am interested to work this out with you, because I just started myself 
this very morning to look at the mod_rewrite module, and I'm curious if 
this is something it can do.
The mod_rewrite capabilities (and docs) are somewhat daunting though, so 
if a specialist could jump it to offer help, it would not be refused.

Here is an example of a request and a response, which I just captured 
with the Firefox add-on "Live Http Headers" :

GET /docs/2.2/images/mod_rewrite_fig2.gif HTTP/1.1
Host: httpd.apache.org
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.15) 
Gecko/20080623 Firefox/2.0.0.15
Accept: image/png,*/*;q=0.5
Accept-Language: en-gb,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://httpd.apache.org/docs/2.2/rewrite/rewrite_intro.html
If-Modified-Since: Tue, 20 Sep 2005 11:00:07 GMT
If-None-Match: "3c12a-9f9-40131f6791bc0"
Cache-Control: max-age=0

HTTP/1.x 304 Not Modified
Date: Fri, 12 Sep 2008 09:33:28 GMT
Server: Apache/2.2.9 (Unix)
Connection: Keep-Alive
Keep-Alive: timeout=5, max=96
Etag: "3c12a-9f9-40131f6791bc0"


 From the look of it, it would seem that none of the lines following the 
initial status line are really essential.
The only one I'm not sure of, is the "Etag", which seems to correspond 
to the request header "If-none-match".

Let's say my first try would be like

RewriteEngine on
RewriteLog /var/log/apache2/mysite/rewrite.log
RewriteLogLevel 9   (so we see what's happening)

<Location /thelocation>
RewriteRule [^/]+\.(gif|jpeg|png)$ - [L]
...
</Location>

And now I'm stuck, because I don't know yet how to tell mod_rewrite to 
send a response with some headers, but no body ..


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by dave selby <da...@googlemail.com>.
2008/9/12 André Warnier <aw...@ice-sa.com>:
> Manik Taneja wrote:
>>
>> Nope, there is no way you can prevent the client from sending you an IMS
>> request.
>
> The above is correct, but if I understand the OP question correctly, the
> basic issue is to make sure that the client does not re-use a cached page,
> but always retrieves the latest page from the server.

Sorry, its me not explaining myself very clearly. Its the opposite.

If you look at kmotion v1 you will see why ....
http://code.google.com/p/kmotion/wiki/ScreenShots its more like an
application than a conventional web page. I have a directory that is
constantly updated with new images, because the directory is
constantly having its 'last modified' date changed apache keeps
resending images that do not need to be sent. And these are not small
files.

None of the images are ever changed, they each have a unique name and
are deleted by background daemons so once loaded I really don't want
to have to reload it again if for arguments sake I need to flip back
to the last frame.

kmotion v1 is alive and well but I am writting v2 & am trying to
improve responsiveness etc.

Sorry for the long explanation - but I hope this explains my problem.

> There is a whole array of things one can do on the server side, to at least
> try to achieve this. I don't recall all the specifics, but look for instance
> at HTTP headers such as "Cache-control".
> See here
> http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
> section 14.9
>
> The general idea is : the server, by a combination of HTTP headers sent
> along with the documents, and tags in the documents themselves, should be
> able to tell the client whether this page can, or cannot, be cached and
> re-used.
> And according to the HTTP specifications, the client (and any intermediate
> proxies) should obey these instructions.
>
> Now whether they always actually do, is anothet issue.
> (But in the practice I have noticed that they generally do).
>
> To modify the HTTP headers that Apache sends along with documents, you could
> use something like this :
> http://httpd.apache.org/docs/2.2/mod/mod_headers.html
> or mod_perl handlers.
>
>
> André
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>  "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
André Warnier wrote:
> Manik Taneja wrote:
>> Nope, there is no way you can prevent the client from sending you an 
>> IMS request. 
> 
> The above is correct, but if I understand the OP question correctly, the 
> basic issue is to make sure that the client does not re-use a cached 
> page, but always retrieves the latest page from the server.
> 
Ooops, it seems I got the question the wrong way around.
But the answer might be useful anyway, just turn it around.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
Manik Taneja wrote:
> Nope, there is no way you can prevent the client from sending you an IMS 
> request. 

The above is correct, but if I understand the OP question correctly, the 
basic issue is to make sure that the client does not re-use a cached 
page, but always retrieves the latest page from the server.

There is a whole array of things one can do on the server side, to at 
least try to achieve this. I don't recall all the specifics, but look 
for instance at HTTP headers such as "Cache-control".
See here
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
section 14.9

The general idea is : the server, by a combination of HTTP headers sent 
along with the documents, and tags in the documents themselves, should 
be able to tell the client whether this page can, or cannot, be cached 
and re-used.
And according to the HTTP specifications, the client (and any 
intermediate proxies) should obey these instructions.

Now whether they always actually do, is anothet issue.
(But in the practice I have noticed that they generally do).

To modify the HTTP headers that Apache sends along with documents, you 
could use something like this :
http://httpd.apache.org/docs/2.2/mod/mod_headers.html
or mod_perl handlers.


André

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by dave selby <da...@googlemail.com>.
2008/9/12 Manik Taneja <mt...@movik.net>:
> Nope, there is no way you can prevent the client from sending you an IMS
> request. That is a browser prerogative, I suppose the best that you can do
> is bump up the Age and Expires headers that are returned along with the
> documents that your server delivers and hope that client browsers use that
> copy every-time.  Even with that if the user refreshes the page, most
> browsers end up sending an IMS.
>
> Thanks,
> Manik

That's a shame. It appears that Apache flags a file as modified if its
parent directory changes its modification time even if the actual file
modification time remains unchanged (The problem i am having). Am I
right in this ?

Dave




-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by Manik Taneja <mt...@movik.net>.
Nope, there is no way you can prevent the client from sending you an IMS 
request. That is a browser prerogative, I suppose the best that you can 
do is bump up the Age and Expires headers that are returned along with 
the documents that your server delivers and hope that client browsers 
use that copy every-time.  Even with that if the user refreshes the 
page, most browsers end up sending an IMS.

Thanks,
Manik

dave selby wrote:
> Is there a way for me to turn off if-modified-since so the client
> browser will ALWAYS use its locally cached document
>
> ie from the definition below Apache always returns a 304 reply ?
>
> "If-Modified-Since: date
> This request header is used with GET method to make it conditional: if
> the requested document has not changed since the time specified in
> this field the document will not be sent, but instead a Not Modified
> 304 reply. "
>
> I realise this is unusual but in my case very needed :)
>
> Many thanks
>
> Dave
>
>
>
>
>
>
>   


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
Jim Britain wrote:
> 
> Re: http://en.wikipedia.org/wiki/HTTP_ETag
>     http://www.iwaw.net/04/Clausen.pdf -- (paragraph: 10)towards the
> end... (worth reading the whole thing) -- details are a little buried,
> pointing toward further research in Apache docs/code.
> 
Very nice refs, thanks.
Information processing and indexing (including of web pages) is my 
business, so I did read the whole thing and found it useful.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Re: way for me to turn off if-modified-since & always return 304 reply ?

Posted by André Warnier <aw...@ice-sa.com>.
Jim Britain wrote:
> On Sat, 13 Sep 2008 08:13:51 +0100, "dave selby"
> <da...@googlemail.com> wrote:
> 
>> 2008/9/12 Scott Gifford <sg...@suspectclass.com>:
>>> "dave selby" <da...@googlemail.com> writes:
>>>
>>>> Is there a way for me to turn off if-modified-since so the client
>>>> browser will ALWAYS use its locally cached document
>>> Dave,
>>>
>>> Usually sending an Expires header will tell browsers to mostly use a
>>> cached version.  I use something like this to set my expires time to
>>> quite a bit in the future:
>>>
>>>   <Directory /path/to/dir>
>>>      ExpiresActive On
>>>      ExpiresDefault A86400000
>>>   </Directory>
>>>
>>> This is part of mod_expires:
>>>
>>>    http://httpd.apache.org/docs/2.0/mod/mod_expires.html
>>>
>>> Also, it would really surprise me if Apache used the parent directory
>>> in deciding about IMS requests.  You might want to do some simple
>>> experiments to verify this is what it's doing.
>> Thank you, thats useful. Something odd is definitely happening.
>>
>> That part of my app as of last night is in pieces (joys of software
>> development) but I am hopeing to rebuild it over the next couple of
>> days. I will do some experiments & repost here.
> 
> Just out of curiosity, I looked up Etags on wikipedia -- most
> interesting, in relation to caching, and what apache uses for
> generation and comparison.
> 
> In short etags are like a cookie.. for changed/unchanged content, and
> is used in combination with the date-time stamp, with preference given
> for the e-tag Z(different e-tag = different content)...  changing the
> inode of a file changes the e-tag...  Apache has mechanisms for
> controlling etag generation...
> 
> Re: http://en.wikipedia.org/wiki/HTTP_ETag
>     http://www.iwaw.net/04/Clausen.pdf -- (paragraph: 10)towards the
> end... (worth reading the whole thing) -- details are a little buried,
> pointing toward further research in Apache docs/code.
> 
I vaguely remembered something like that, which is why I mentioned it.
I was thinking that if one really wanted to fool the browser, one may 
need to add an Etag: header, with the same value as what the browser 
sent. That would be possible using SetEnvIf and mod_rewrite and 
mod_headers. But maybe just ignoring the Etag header has the same result.

I have started to play with mod_rewrite in the meantime, for another 
issue. It's amazing what that thing can do.  And it is a standard Apache 
2.x component, so if your application is based on Apache being there 
anyway, you would not introduce anything "foreign" by using it.
mod_headers and mod_rewrite also by the way.
It seems a pity not to use these tools if they are available.

I have an application that runs on multiple platforms (Solaris, HPUX, 
various Linuxes, Win32), based on Apache, mod_perl (perl integration in 
Apache), and to a lesser extent Tomcat and thus Java.  So far, over 
several years, I have not encountered any serious incompatibilities 
between platforms with any of these packages. Your mileage may vary of 
course.

All of the above rests on the assumption that you have a problem because 
Apache considers the image files as modified for some reason.  As 
someone pointed out however, that looks suspicious, and should really be 
checked first.

Another tidbit that comes to mind, is that the browser is not the only 
agent that may play a role here : there could be any number of proxies 
between your server and the browser, and one of them might decide to 
re-retrieve the object for some reason of its own.  So you might still 
want to make sure that you are setting the proper caching HTTP headers, 
or at least not setting some that prevent caching.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


[users@httpd] Re: way for me to turn off if-modified-since & always return 304 reply ?

Posted by Jim Britain <no...@suddenlink.net>.
On Sat, 13 Sep 2008 08:13:51 +0100, "dave selby"
<da...@googlemail.com> wrote:

>2008/9/12 Scott Gifford <sg...@suspectclass.com>:
>> "dave selby" <da...@googlemail.com> writes:
>>
>>> Is there a way for me to turn off if-modified-since so the client
>>> browser will ALWAYS use its locally cached document
>>
>> Dave,
>>
>> Usually sending an Expires header will tell browsers to mostly use a
>> cached version.  I use something like this to set my expires time to
>> quite a bit in the future:
>>
>>   <Directory /path/to/dir>
>>      ExpiresActive On
>>      ExpiresDefault A86400000
>>   </Directory>
>>
>> This is part of mod_expires:
>>
>>    http://httpd.apache.org/docs/2.0/mod/mod_expires.html
>>
>> Also, it would really surprise me if Apache used the parent directory
>> in deciding about IMS requests.  You might want to do some simple
>> experiments to verify this is what it's doing.
>
>Thank you, thats useful. Something odd is definitely happening.
>
>That part of my app as of last night is in pieces (joys of software
>development) but I am hopeing to rebuild it over the next couple of
>days. I will do some experiments & repost here.

Just out of curiosity, I looked up Etags on wikipedia -- most
interesting, in relation to caching, and what apache uses for
generation and comparison.

In short etags are like a cookie.. for changed/unchanged content, and
is used in combination with the date-time stamp, with preference given
for the e-tag Z(different e-tag = different content)...  changing the
inode of a file changes the e-tag...  Apache has mechanisms for
controlling etag generation...

Re: http://en.wikipedia.org/wiki/HTTP_ETag
    http://www.iwaw.net/04/Clausen.pdf -- (paragraph: 10)towards the
end... (worth reading the whole thing) -- details are a little buried,
pointing toward further research in Apache docs/code.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by dave selby <da...@googlemail.com>.
2008/9/12 Scott Gifford <sg...@suspectclass.com>:
> "dave selby" <da...@googlemail.com> writes:
>
>> Is there a way for me to turn off if-modified-since so the client
>> browser will ALWAYS use its locally cached document
>
> Dave,
>
> Usually sending an Expires header will tell browsers to mostly use a
> cached version.  I use something like this to set my expires time to
> quite a bit in the future:
>
>   <Directory /path/to/dir>
>      ExpiresActive On
>      ExpiresDefault A86400000
>   </Directory>
>
> This is part of mod_expires:
>
>    http://httpd.apache.org/docs/2.0/mod/mod_expires.html
>
> Also, it would really surprise me if Apache used the parent directory
> in deciding about IMS requests.  You might want to do some simple
> experiments to verify this is what it's doing.

Thank you, thats useful. Something odd is definitely happening.

That part of my app as of last night is in pieces (joys of software
development) but I am hopeing to rebuild it over the next couple of
days. I will do some experiments & repost here.

Cheers

Dave






>
> ----Scott.
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>



-- 

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] way for me to turn off if-modified-since & always return 304 reply ?

Posted by Scott Gifford <sg...@suspectclass.com>.
"dave selby" <da...@googlemail.com> writes:

> Is there a way for me to turn off if-modified-since so the client
> browser will ALWAYS use its locally cached document

Dave,

Usually sending an Expires header will tell browsers to mostly use a
cached version.  I use something like this to set my expires time to
quite a bit in the future:

   <Directory /path/to/dir>
      ExpiresActive On
      ExpiresDefault A86400000
   </Directory>

This is part of mod_expires:

    http://httpd.apache.org/docs/2.0/mod/mod_expires.html

Also, it would really surprise me if Apache used the parent directory
in deciding about IMS requests.  You might want to do some simple
experiments to verify this is what it's doing.

----Scott.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org