You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Gregor Schneider <rc...@googlemail.com> on 2006/08/02 21:05:39 UTC

[users@httpd] mod_expires not working

hi guys,

I'm getting nuts here. This is what i have:

Apache HTTPD 2.0.48, Suse 9 something, Tomcat 5.0.28 working together with
Apache HTTPD via mod_jk.

I have loaded and included both mod_headers and mod_expires (verified via
https:/.../server-info), however, something puzzels me here:

First, I'm attaching my mod_headers.conf and mod_expires.conf:

mod_headers.conf:

      1 <IfModule mod_headers.c>
      2    Header unset Pragma
      3    Header set Connection: close env=object_is_pdf
      4    Header set ServerTokens MIN
      5    Header set Cache-Control "public,must-revalidate"
      6 </IfModule>

mod_expires.conf:

      1 <IfModule mod_expires.c>
      2         ExpiresActive On
      3         ExpiresDefault "now plus 10 seconds"
      4         ExpiresByType image/gif "now plus 3 months"
      5         ExpiresByType image/jpeg "now plus 3 months"
      6         ExpiresByType text/html "now plus 3 months"
      7         ExpiresByType text/xml "now plus 3 months"
      8         ExpiresByType text/javascript "now plus 3 months"
      9         ExpiresByType application/pdf "now plus 3 months"
     10 </IfModule>

Line 3 is to work around the IE-bug that you cannot download f.e. pdf's via
SSL, the mod_setenvif.conf is missing here, but this is not the point.

I would expect that I'm getting a response-header saying something like

Expires: Thu, 01 Nov 2006 22:00:00 CET

However, what's coming back is   "Expires: Thu, 01 Jan 1970 01:00:00 CET".

Since we have not implemented a form-based SSO between Apache HTTPD and
Tomcat, we do have to serve our static HTML-content via Tomcat, and I can
see that this header is definately created by Tomcat. When I go directly to
Tomcat via https://myhost:8080/somehtml.html, I get exactly this header,
too.

Now here's my question:

Why does mod_headers not seem to work here? What am I getting wrong?
Please note that I'm quite a newbie to Apache HTTPD and Tomcat, so I might
ask some dumb questions...

Any hints are greatly appreciated!

Cheers & TIA!

Gregor
-- 
what's puzzlin' you, is the nature of my game

Re: [users@httpd] mod_expires not working

Posted by Gregor Schneider <rc...@googlemail.com>.
Hi Joshua,

On 8/3/06, Joshua Slive <jo...@slive.ca> wrote:

> The point is, if you know you need those modules, those lines do
> > absolutely nothing positive and may deceive you into thinking nothing
> > is wrong if the modules are ever removed.


ok, got that


> > That's all a tomcat issue that would be better addressed on a tomcat
> list.
>
> I've just fixed it - now the filter is working :)



> This is actually the first I've ever heard of someone trying to
> > override an Expires header.


Well, I don't want to OVERWRITE the header but to SET it to optimize
caching. Actually, this is done with mod_expires, however, since we're
forced to serve our HTML via Tomcat *sic*, we have the problem that Tomcat
always adds the fixed header "Expires Thu, 01.01.1970...." to any
static content
(like html, js, gifs
etc.), and hence mod_expires from Apache HTTP won't do anything.
Now, with this filter I can set the header at least to the value that is
needed to optimize caching on the client-side.

Anyways, thanks a lot for your help, I'll call it a day now...

Gregor
-- 
what's puzzlin' you, is the nature of my game

Re: [users@httpd] mod_expires not working

Posted by Joshua Slive <jo...@slive.ca>.
> > All the <IfModule ...> and </IfModule> lines just hide useful error
> > messages.  Get rid of them.
>
> ehem - could you explain that to me? I don't see the
> sence. If you're hinting that I could
> figure out wether a module is installed or not,
> I can see that via server-info - or do I miss your point here?

The point is, if you know you need those modules, those lines do
absolutely nothing positive and may deceive you into thinking nothing
is wrong if the modules are ever removed.

> > > My understanding is that mod_expires acts only if no existing Expires
> > > header exists.  It will not override existing headers.
>
>
> hm, if it's really that, this would be bad news. Can I find
> this statement somewhere in the docs (didn't find it, yet).

This is from a very quick scan of the code.  I didn't really check definitively.

> Currently I'm
> trying to write a filter in Tomcat to set
> the Expires-Header, however, if I use

That's all a tomcat issue that would be better addressed on a tomcat list.

This is actually the first I've ever heard of someone trying to
override an Expires header.

Joshua.

---------------------------------------------------------------------
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] mod_expires not working

Posted by Gregor Schneider <rc...@googlemail.com>.
Hi Joshua,

first, thanks for the info.

Anyhow, a few questions:

On 8/3/06, Joshua Slive <jo...@slive.ca> wrote:
>
> > > Apache HTTPD 2.0.48, Suse 9 something, Tomcat 5.0.28 working together
> with
> > > Apache HTTPD via mod_jk.
>
> > Rather old version of apache.
>
> actually it's 2.0.49 - however, we do prefer some stable version here
> which undergo internal and external testing,
> therefore chaning apache is not an option. Besides, I don't think that this would solve my problem.
>
> >
>
> > All the <IfModule ...> and </IfModule> lines just hide useful error
> > messages.  Get rid of them.


ehem - could you explain that to me? I don't see the sence. If you're
hinting that I could figure out wether a module is installed or not,
I can see that via server-info - or do I miss your point here?

>
> > I don't think you really want an HTTP header called ServerTokens.
> > Perhaps you want to see the ServerTokens directive.


ok, will do that

> My understanding is that mod_expires acts only if no existing Expires
> > header exists.  It will not override existing headers.


hm, if it's really that, this would be bad news. Can I find this statement
somewhere in the docs (didn't find it, yet).
Currently I'm trying to write a filter in Tomcat to set the
Expires-Header, however, if I use

response.setHeader("Expires:",
createExpiresHeader()); in the doFilter(...)-method of my filter, the
header also looks somewhat awkward:
(the createExpiresHeader() creates the date-string)

Expires: Thu, 01 Jan 1970 01:00:00 CET, : Thu, 3 Aug 2006 20:13:10 CEST

Seems I don't have any option to unset the header first. To me this would
look like a bug in Tomcat, since I'm expecting the method
response.setHeader(...)
to SET a header and not APPEND any content to an existing one.

I can, however, unset the header using mod_headers, currently I'm looking if
there's any regex to SET the header via mod_headers to the current date/time
plus 1 month - any idea, how I could do that?

Cheers!

Gregor
-- 
what's puzzlin' you, is the nature of my game

Re: [users@httpd] mod_expires not working

Posted by Joshua Slive <jo...@slive.ca>.
On 8/2/06, Gregor Schneider <rc...@googlemail.com> wrote:
> hi guys,
>
> I'm getting nuts here. This is what i have:
>
> Apache HTTPD 2.0.48, Suse 9 something, Tomcat 5.0.28 working together with
> Apache HTTPD via mod_jk.

Rather old version of apache.

>
> I have loaded and included both mod_headers and mod_expires (verified via
> https:/.../server-info), however, something puzzels me here:
>
> First, I'm attaching my mod_headers.conf and mod_expires.conf:
>
> mod_headers.conf:
>
>       1 <IfModule mod_headers.c>

All the <IfModule ...> and </IfModule> lines just hide useful error
messages.  Get rid of them.

>       2    Header unset Pragma
>       3    Header set Connection: close env=object_is_pdf
>       4    Header set ServerTokens MIN

I don't think you really want an HTTP header called ServerTokens.
Perhaps you want to see the ServerTokens directive.

>       5    Header set Cache-Control "public,must-revalidate"
>       6 </IfModule>
>
> mod_expires.conf:
>
>       1 <IfModule mod_expires.c>
>       2         ExpiresActive On
>       3         ExpiresDefault "now plus 10 seconds"
>       4         ExpiresByType image/gif "now plus 3 months"
>       5         ExpiresByType image/jpeg "now plus 3 months"
>       6         ExpiresByType text/html "now plus 3 months"
>       7         ExpiresByType text/xml "now plus 3 months"
>       8         ExpiresByType text/javascript "now plus 3 months"
>       9         ExpiresByType application/pdf "now plus 3 months"
>      10 </IfModule>
>
> Line 3 is to work around the IE-bug that you cannot download f.e. pdf's via
> SSL, the mod_setenvif.conf is missing here, but this is not the point.
>
> I would expect that I'm getting a response-header saying something like
>
> Expires: Thu, 01 Nov 2006 22:00:00 CET
>
> However, what's coming back is   "Expires: Thu, 01 Jan 1970 01:00:00 CET".
>
> Since we have not implemented a form-based SSO between Apache HTTPD and
> Tomcat, we do have to serve our static HTML-content via Tomcat, and I can
> see that this header is definately created by Tomcat. When I go directly to
> Tomcat via https://myhost:8080/somehtml.html, I get exactly
> this header, too.
>
> Now here's my question:
>
> Why does mod_headers not seem to work here? What am I getting wrong?
> Please note that I'm quite a newbie to Apache HTTPD and Tomcat, so I might
> ask some dumb questions...

My understanding is that mod_expires acts only if no existing Expires
header exists.  It will not override existing headers.

Joshua.

---------------------------------------------------------------------
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