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.
*/