You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Brian J. France" <li...@firehawksystems.com> on 2008/04/28 21:10:14 UTC

mod_deflate Vary header tweak

I would like to propose a change to mod_deflate that would still send  
the Vary header if the request is flagged with no-gzip or gzip-only- 
text/html.

I think the checks for Content-Range and Content-Encoding should be  
done, then the Vary header should be set and then the checks for no- 
gzip and gzip-only-text/html should be done.

Thoughts?

Brian


Index: mod_deflate.c
===================================================================
--- mod_deflate.c       (revision 652071)
+++ mod_deflate.c       (working copy)
@@ -422,34 +422,12 @@
              return ap_pass_brigade(f->next, bb);
          }

-        /* some browsers might have problems, so set no-gzip
-         * (with browsermatch) for them
-         */
-        if (apr_table_get(r->subprocess_env, "no-gzip")) {
-            ap_remove_output_filter(f);
-            return ap_pass_brigade(f->next, bb);
-        }
-
          /* We can't operate on Content-Ranges */
          if (apr_table_get(r->headers_out, "Content-Range") != NULL) {
              ap_remove_output_filter(f);
              return ap_pass_brigade(f->next, bb);
          }

-        /* Some browsers might have problems with content types
-         * other than text/html, so set gzip-only-text/html
-         * (with browsermatch) for them
-         */
-        if (r->content_type == NULL
-             || strncmp(r->content_type, "text/html", 9)) {
-            const char *env_value = apr_table_get(r->subprocess_env,
-                                                  "gzip-only-text/ 
html");
-            if ( env_value && (strcmp(env_value,"1") == 0) ) {
-                ap_remove_output_filter(f);
-                return ap_pass_brigade(f->next, bb);
-            }
-        }
-
          /* Let's see what our current Content-Encoding is.
           * If it's already encoded, don't compress again.
           * (We could, but let's not.)
@@ -500,6 +478,28 @@
           */
          apr_table_mergen(r->headers_out, "Vary", "Accept-Encoding");

+        /* some browsers might have problems, so set no-gzip
+         * (with browsermatch) for them
+         */
+        if (apr_table_get(r->subprocess_env, "no-gzip")) {
+            ap_remove_output_filter(f);
+            return ap_pass_brigade(f->next, bb);
+        }
+
+        /* Some browsers might have problems with content types
+         * other than text/html, so set gzip-only-text/html
+         * (with browsermatch) for them
+         */
+        if (r->content_type == NULL
+             || strncmp(r->content_type, "text/html", 9)) {
+            const char *env_value = apr_table_get(r->subprocess_env,
+                                                  "gzip-only-text/ 
html");
+            if ( env_value && (strcmp(env_value,"1") == 0) ) {
+                ap_remove_output_filter(f);
+                return ap_pass_brigade(f->next, bb);
+            }
+        }
+
          /* force-gzip will just force it out regardless if the browser
           * can actually do anything with it.
           */


Re: mod_deflate Vary header tweak

Posted by Henrik Nordstrom <he...@henriknordstrom.net>.
On tis, 2008-04-29 at 09:42 +0200, André Malo wrote:

> Just to be exact - it *might* vary, depending on how no-gzip is set. 

But then most likely not based on Accept-Encoding but other headers such
as User-Agent or the source IP...

In any event I fully agree that it's then the responsibility of whatever
that set the no-gzip flag to also add a proper Vary attribution to the
response.

Only if no-gzip is set unconditionall should Vary not be added by the
one setting no-gzip. But it's acceptable (even if not 100% correct) to
not add Vary when setting no-gzip if one then accepts that the
uncompressed variant ay get sent to more clients by downstream cache
servers.

Regards
Henrik


Re: mod_deflate Vary header tweak

Posted by André Malo <nd...@perlig.de>.
* Nick Kew wrote: 


> On Mon, 28 Apr 2008 15:10:14 -0400
>
> "Brian J. France" <li...@firehawksystems.com> wrote:
> > I would like to propose a change to mod_deflate that would still
> > send the Vary header if the request is flagged with no-gzip or
> > gzip-only- text/html.
>
> But if no-gzip is set, then the response will not be compressed,
> regardless of the Accept-Encoding header.  So it doesn't vary.

Just to be exact - it *might* vary, depending on how no-gzip is set. 
However, this is still not within the scope of mod_deflate. Thatswhy we 
have provided this sample configuration in the mod_deflate docs together 
with mod_headers.

nd



Re: mod_deflate Vary header tweak

Posted by Nick Kew <ni...@webthing.com>.
On Mon, 28 Apr 2008 15:10:14 -0400
"Brian J. France" <li...@firehawksystems.com> wrote:

> I would like to propose a change to mod_deflate that would still
> send the Vary header if the request is flagged with no-gzip or
> gzip-only- text/html.

But if no-gzip is set, then the response will not be compressed,
regardless of the Accept-Encoding header.  So it doesn't vary.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.apachetutor.org/