WebLogic Server 10.x Cache Filter Ignores the HTTP Request Content-Encoding Header (Doc ID 1052672.1)

Last updated on FEBRUARY 11, 2017

Applies to:

Oracle Weblogic Server - Version: 10.0 to 10.3
Information in this document applies to any platform.

Symptoms

When using the Weblogic Server (WLS) cache filter (weblogic.cache.filter.CacheFilter) and when the response header Content-Encoding is set to
response.setHeader("Content-Encoding","gzip");

a Content Encoding Error is encountered when the page is hit the first time:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.

To reproduce this issue:

Run a simple web application on your WLS domain with the WebLogic cache filter configured in WEB-INF/web.xml as below:
<filter>
<filter-name>HTML</filter-name>
<filter-class>weblogic.cache.filter.CacheFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>HTML</filter-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>


Then use the following code snippet in the test.jsp to print out the headers:
<%
java.util.Enumeration en=request.getHeaderNames();
while(en.hasMoreElements())
{
String header = (String)en.nextElement();
String value = request.getHeader(header);
out.println("header:"+"value+"");
response.setHeader("Content-Encoding","gzip");
}
%>

You can use a tool like Live Http Headers to monitor HTTP headers in Mozilla Firefox, Click Tools->Live Http headers. You will see results like this for the first request:
GET /test/test.jsp HTTP/1.1
Host: localhost:7001
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive

HTTP/1.x 200 OK
Date: Fri, 22 Jan 2010 08:41:58 GMT
Content-Length: 803
Content-Type: text/html; charset=ISO-8859-1
Last-Modified: Fri, 22 Jan 2010 08:42:11 GMT
Content-Encoding: gzip
Set-Cookie: JSESSIONID=bSvxLZkDyhTQxjYmMqjmwz1jnJTJBJDvxMbPJQyVm12wv32PVNtX!-1799442524; path=/
X-Powered-By: Servlet/2.5 JSP/2.1

The request headers for subsequent requests are missing the content-encoding header:
GET /test/test.jsp HTTP/1.1
Host: localhost:7001
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Cookie: JSESSIONID=bSvxLZkDyhTQxjYmMqjmwz1jnJTJBJDvxMbPJQyVm12wv32PVNtX!-1799442524

HTTP/1.x 200 OK
Date: Fri, 22 Jan 2010 08:43:17 GMT
Content-Length: 803
Content-Type: text/html
Last-Modified: Fri, 22 Jan 2010 08:42:11 GMT
X-Powered-By: Servlet/2.5 JSP/2.1

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms