RE: [users@httpd] mod_cache: CacheDefaultExpire is ignored?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That's the problem: as far as I remember, mod_expires adds the Expires header after mod_cache has declined to cache the response. Therefore, adding the expires header will not cause Apache to cache the response, but the client agents (navigators) will.

If you can verify that what I wrote is correct, you may still have a way to add the expires header before mod_cache intervenes by adding a reverse proxy virtual host to your Apache server, at the expense of an additional HTTP request.

                 __________     ___________     
                 |         |    |          |
client ----------| reverse |----|    CGI   | 
                 |  proxy  |    |   server |
                 -----------    ------------

The role of the reverse proxy would be:
- pass the requests to the CGI server using ProxyPass/ProxyPassReverse
- cache the responses

The CGI server:
- generate/serve contents
- add the appropriate headers

You can do everything within the same Apache server by having two separate virtual hosts, one for the RP and one for the CGI. The latter can listen on 127.0.0.1.


-ascs

-----Original Message-----
From: Frans Knibbe [mailto:frans@xxxxxxxxx] 
Sent: Thursday, March 09, 2006 10:34 AM
To: users@xxxxxxxxxxxxxxxx
Subject: Re: [users@httpd] mod_cache: CacheDefaultExpire is ignored?

Thanks for the explanation! At least this means  that the description of CacheDefaultExpire is somewhat misleading , I  think.
I don't use a reverse proxy and I have little control over the output from the CGI program, but maybe mod_expires or mod_headers can add the header before mod_cache evaluates the response?

Kind regards,

Frans Knibbe

 

Axel-Stéphane SMORGRAV wrote:
> The problem is that the response contains no cache validator: no Last-Modified, no E-Tag.  If it contains no cache validator, it must contain an explicit expiry date in order to be cacheable. Look at sections 13.3 and 13.4 of RFC 2616.
>
> Your problem is typical of files generated by a servlet, or more generally by an application and not served by a http server or the file servlet of an application server.
>
> You can have the application add a cache validator to the response, or you can use ExpiresActive/ExpiresByType/ExpiresDefault to have your reverse proxy add the Expires header. The problem is that I believe that the Expires header in that case will be added after mod_cache has decided to decline to cache, but you can try it anyway.
>
> -ascs
>
> -----Original Message-----
> From: Frans Knibbe [mailto:frans@xxxxxxxxx]
> Sent: Wednesday, March 08, 2006 3:58 PM
> To: users@xxxxxxxxxxxxxxxx
> Subject: [users@httpd] mod_cache: CacheDefaultExpire is ignored?
>
> Hello,
>
> I use apache 2.0.55 on Windows and I am experiencing a problem using mod_cache.
>
> It is my intention to use a memory cache for images produced by a CGI program. Here is the relevant bit of httpd.conf:
>
> <IfModule mod_cache.c>
>   LoadModule mem_cache_module modules/mod_mem_cache.so
>   <IfModule mod_mem_cache.c>
>     CacheDefaultExpire 86400
>     CacheEnable mem /
>     MCacheSize 4096
>     MCacheMaxObjectCount 10000
>     MCacheMinObjectSize 1
>     MCacheMaxObjectSize 104857600
>     MCacheMaxStreamingBuffer 104857600
>     MCacheSize 409600
>   </IfModule>
> </IfModule>
>
> If I let Apache log debug information, I can see that caching is active. 
> Some caching takes place, but not the images I want cached. In that case,  something like this is reported:
>
> [Wed Mar 08 14:09:11 2006] [debug] mod_cache.c(446): cache: <request> 
> not cached. Reason: Query string present but no expires header
>
> There is no expiration time in the header, that is true, but shouldn't CacheDefaultExpire be used in that case? In the documentation it says: 
> "The CacheDefaultExpire directive specifies a default time, in seconds, to cache a document if neither an expiry date nor last-modified date are provided with the document". So if there is no expires header the expiry time should be set to one day (86400 seconds) in this case, right?
>
> Am I overlooking something? How can I get caching to work?
>
> Thanks in advance,
>
> Frans Knibbe
>
>
>
>
> ---------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>
> ---------------------------------------------------------------------
> 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@xxxxxxxxxxxxxxxx
>    "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
> For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx
>
>
>
>
>   



---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux