• Bug
  • Status: Closed
  • 2 Major
  • Resolution: Fixed
  • ehcache-web
  • hhuynh
  • Reporter: thaiha
  • July 15, 2010
  • 0
  • Watchers: 3
  • July 27, 2012
  • October 05, 2010


To support HTTP proxies which caching gzipped content, GzipFilter should send the header “Vary: Accept-Encoding” (similar to the way httpd’s mod_defalate is working). We should also handle the case where a Vary header already so we will not accidentally override the existing values.


Steve Harris 2010-07-16

Hey hung, check with greg and make sure this isn’t a bad idea and if it is the right thing to do fix it once things settle down.

gluck 2010-07-19

What behaviour are you seeing? There are lot of people using that at is is.

Thai Ha 2010-07-19

I don’t observe any error with my webapp, but I worry that some users who accessing my webapp using old browsers behind HTTP proxies might have problems. While it is not an issue for modern browsers, it is still a good idea to support old browsers.

Some references below.

“The mod_deflate module sends a Vary: Accept-Encoding HTTP response header to alert proxies that a cached response should be sent only to clients that send the appropriate Accept-Encoding request header. This prevents compressed content from being sent to a client that will not understand it.” (from http://httpd.apache.org/docs/2.0/mod/mod_deflate.html)


“There are known issues with browsers and proxies that may cause a mismatch in what the browser expects and what it receives with regard to compressed content. Fortunately, these edge cases are dwindling as the use of older browsers drops off. The Apache modules help out by adding appropriate Vary response headers automatically. “ (from http://developer.yahoo.net/blog/archives/2007/07/high_performanc_3.html)

gluck 2010-07-19

ehcache-web is used on some of the world’s busiest web sites.

It only sends gzipped content and the header where a request header advertises GZip encoding. Otherwise the content is sent back ungzipped.

A common proxy scenario is Microsoft proxy. It used to strip off the accepts: gzip request header in the case of Internet Explorer. This does not cause an error, but simply means that the response is uncompressed, which is suboptimal.

The Vary header is HTTP 1.1 only. Ehcache-web will also work with HTTP 1.0

Reading the various specs they don’t really say what happens when you don’t set Vary. Reading http://www8.org/w8-papers/5c-protocols/key/key.html, it looks like the whole URL is used as the key.

Thai Ha 2010-07-19

I believe that it is OK for a web server to send an HTTP 1.1 header to a HTTP 1.0 browser if server doesn’t depend on the recipient understanding it. See http://greenbytes.de/tech/webdav/rfc2145.html#rfc.section.2.2

I don’t see Vary: Accept-Encoding is required in standard documents. But it is mentioned in source code/documents of many web servers.

mod_deflate of Apache HTTPD: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/filters/mod_deflate.c?view=markup

Tomcat web server: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/Http11AprProcessor.java?view=markup

Sun Java System Web Server: http://docs.sun.com/app/docs/doc/820-5704/bhatq?a=view

For IIS server: http://www.winserverkb.com/Uwe/Forum.aspx/iis/6230/Howto-disable-Vary-header-in-IIS-6-0 (see the command from Anil Ruia, Microsoft)

Hung Huynh 2010-07-20

Greg, please let me know what to do regarding this one

gluck 2010-07-20

Ok, let’s do it.

It should be a configuration option, with the default set to off, i.e. do not include the header. Sun Java System Web Server makes it a config option.

It should be a parameter in the filter config.

Hung Huynh 2010-10-05

set this param to true to enable Vary header