Project

General

Profile

Actions

Bug #1997

closed

mod_expire overwrites header Cache-Control

Added by eddi over 15 years ago. Updated over 15 years ago.

Status:
Fixed
Priority:
Low
Category:
mod_expire
Target version:
ASK QUESTIONS IN Forums:

Description

Hi,

mod_expire.c; line 345; function URIHANDLER_FUNC()

My english is not that good, but let me try to explain why overwritten header Cache-Control maybe have unwanted effects. By this behavior values like RFC 2616 section 14.9.* will be not send. The given cache policy forfeit for resources. For example I set Cache-Control: no-transform, private and I like to manifest an expire, an intermediate cache could transform and/or store it unwanted.

Easiest way could be, leave this header untouched by mod_expire. So an admin have to advocate for its own oppositional configuration.

With best regrads from Berlin

Actions #1

Updated by darix over 15 years ago

can you please add the relevant parts of your config?

Actions #2

Updated by stbuehler over 15 years ago

  • Target version changed from 1.4.23 to 1.4.24
Actions #3

Updated by eddi over 15 years ago

$HTTP["url"] =~ "\.(bmp|gif|jpg|png|tiff|psd|xbm|xpm|xwd)$" {
expire.url =(""=>"access 10 days")
setenv.add-response-header=("Cache-Control"=>"private,no-transform")
}

In my opinion it is caused by mod_expire.c, lines 342 till 345.

buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
buffer_append_long(p->expire_tstmp, ts);
response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
Actions #4

Updated by stbuehler over 15 years ago

We will not change the current behaviour. If you need customized behaviour, you should probably use mod_magnet (or patch lighty yourself).

Actions #5

Updated by darix over 15 years ago

eddi wrote:

> $HTTP["url"]    =~ ".(bmp|gif|jpg|png|tiff|psd|xbm|xpm|xwd)$" {
>    expire.url                =(""=>"access 10 days")
>    setenv.add-response-header=("Cache-Control"=>"private,no-transform")
> }
> 

In my opinion it is caused by mod_expire.c, lines 342 till 345.

buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
buffer_append_long(p->expire_tstmp, ts);

response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));

does it help if you load mod_expire before mod_setenv? order matters.

Actions #6

Updated by stbuehler over 15 years ago

setenv only appends a second header, expire overwrites it. So no combination is going to work.

Actions #7

Updated by eddi over 15 years ago

  • % Done changed from 0 to 90

Here is a patch

345c345
<                       response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
---
>                       response_header_insert(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));

That's it. It works. It is that plain. It is conform on RFC.

stbuehler wrote:

We will not change the current behaviour. If you need customized behaviour, you should probably use mod_magnet (or patch lighty yourself).

Best way should be to merge values of Cache-Control without include 3rd modules. I please you add it.

With best regrads from Berlin
eddi

Actions #8

Updated by stbuehler over 15 years ago

This has nothing to do with rfc conform.

mod_magnet is one module, mod_setenv + mod_expire are two modules... so i don't see your problem with mod_magnet.

patches should be created with diff -u, and you should use the "pre" formatting if you inline it. better attach patches to preserve whitespaces.

Actions #9

Updated by eddi over 15 years ago

stbuehler wrote:

This has nothing to do with rfc conform.

Right.

stbuehler wrote:

mod_magnet is one module, mod_setenv + mod_expire are two modules... so i don't see your problem with mod_magnet.

Right.
My problem: mod_expire comput date of expiration. mod_magnet requires lua on my system to do so as well. mod_magnet requires I have to learn lua, I have to program. Configuration is not longer placed in one file, but would have differed syntax too.

I like to configure lighttpd with KISS in my mind.

stbuehler wrote:

patches should be created with diff -u, and you should use the "pre" formatting if you inline it. better attach patches to preserve whitespaces.

I am sorry.

--- mod_expire.c.old    2009-06-12 20:41:17.215317444 +0200
+++ mod_expire.c        2009-06-12 21:23:02.250151671 +0200
@@ -342,7 +342,7 @@
                        buffer_copy_string_len(p->expire_tstmp, CONST_STR_LEN("max-age="));
                        buffer_append_long(p->expire_tstmp, ts);

-                       response_header_overwrite(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));
+                       response_header_insert(srv, con, CONST_STR_LEN("Cache-Control"), CONST_BUF_LEN(p->expire_tstmp));

                        return HANDLER_GO_ON;
                }
Actions #10

Updated by stbuehler over 15 years ago

  • Status changed from New to Fixed

Fixed in r2589 (wrong commit message)

Actions #11

Updated by eddi over 15 years ago

  • % Done changed from 90 to 100

Thanks. :)))

With best regrads from Berlin
eddi

Actions

Also available in: Atom