httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 54518] New: mod_rewrite not adding Vary header
Date Fri, 01 Feb 2013 22:09:12 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=54518

            Bug ID: 54518
           Summary: mod_rewrite not adding Vary header
           Product: Apache httpd-2
           Version: 2.4.3
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
          Assignee: bugs@httpd.apache.org
          Reporter: daniel.lescohier@cnet.com
    Classification: Unclassified

mod_rewrite is supposed to append to the Vary HTTP response header any HTTP
request headers used in RewriteCond statements.

This doesn't seem to work.

Relevant conf:

<Directory ${docroot}/js>
  ExpiresActive On
  ExpiresDefault "access plus 30 minutes"

  SetEnvIf Via AkamaiGHost VIA_AKAMAI_EDGE # ch.8 of Edge Server Config Guide
# Only set Edge-Control if via Akamai Edge server, so as to
# not increase size of response to non-Akamai clients
  Header set Edge-Control max-age=1800 env=VIA_AKAMAI_EDGE

  FileETag MTime Size

  RewriteEngine On
  RewriteCond %{HTTP:Accept-Encoding}
(^|,)\s*(x-)?gzip(?!\s*;\s*qs\s*=\s*0([.]0{0,3})?(\s|,|$))
  RewriteRule (.*)[.]js$ $1.js.gz
</Directory>

And the response headers I get back:

HTTP/1.1 200 OK
Date: Fri, 01 Feb 2013 21:41:30 GMT
Server: Apache/2.4.3
Last-Modified: Wed, 09 Jan 2013 16:57:50 GMT
ETag: "1a27-4d2ddf660ff80"
Accept-Ranges: bytes
Content-Length: 6695
Cache-Control: max-age=1800
Expires: Fri, 01 Feb 2013 22:11:30 GMT
P3P: CP="CAO DSP COR CURa ADMa DEVa PSAa PSDa IVAi IVDi CONi OUR OTRi IND PHY
ONL UNI FIN COM NAV INT DEM STA"
Content-Type: application/javascript
Content-Encoding: application/gzip


I have a workaround of adding these two lines to the Directory section:

SetEnvIf Accept-Encoding
(^|,)\s*(x-)?gzip(?!\s*;\s*qs\s*=\s*0([.]0{0,3})?(\s|,|$)) VARY_ACCEPT_ENCODING
Header append Vary Accept-Encoding env=VARY_ACCEPT_ENCODING

Then I get back:

HTTP/1.1 200 OK
Date: Fri, 01 Feb 2013 21:42:53 GMT
Server: Apache/2.4.3
Last-Modified: Wed, 09 Jan 2013 16:57:50 GMT
ETag: "1a27-4d2ddf660ff80"
Accept-Ranges: bytes
Content-Length: 6695
Cache-Control: max-age=1800
Expires: Fri, 01 Feb 2013 22:12:53 GMT
Vary: Accept-Encoding
P3P: CP="CAO DSP COR CURa ADMa DEVa PSAa PSDa IVAi IVDi CONi OUR OTRi IND PHY
ONL UNI FIN COM NAV INT DEM STA"
Content-Type: application/javascript
Content-Encoding: application/gzip

But adding these extra two lines of config should not be necessary, because
mod_rewrite is supposed to do it. I see the code in the module (high-level part
pasted below), but it doesn't seem to be doing it.

        ctx->vary = NULL;
        rc = apply_rewrite_rule(p, ctx);

        if (rc) {
            /* Regardless of what we do next, we've found a match. Check to see
             * if any of the request header fields were involved, and add them
             * to the Vary field of the response.
             */
            if (ctx->vary) {
                apr_table_merge(r->headers_out, "Vary", ctx->vary);
            }

The rewrite rule itself is working; the response has the content-encoded
application/gzip file of 6695 bytes.  When I do a request with no
Accept-Encoding: gzip header, I get the uncompressed file and response:

HTTP/1.1 200 OK
Date: Fri, 01 Feb 2013 21:41:06 GMT
Server: Apache/2.4.3
Last-Modified: Wed, 09 Jan 2013 16:57:48 GMT
ETag: "523d-4d2ddf6427b00"
Accept-Ranges: bytes
Content-Length: 21053
Cache-Control: max-age=1800
Expires: Fri, 01 Feb 2013 22:11:06 GMT
P3P: CP="CAO DSP COR CURa ADMa DEVa PSAa PSDa IVAi IVDi CONi OUR OTRi IND PHY
ONL UNI FIN COM NAV INT DEM STA"
Content-Type: application/javascript

It's just the adding of the Vary header which is not working in the mod_rewrite
module.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


Mime
View raw message