On JBoss 4.2.3.GA - JSP response header transfer-encoding:chunked makes it so I can't cache jsp content on load balancer

StackOverflow https://stackoverflow.com/questions/10127730

Question

On JBoss 4.2.3.GA, we have a JSP response that is being generated with transfer-encoding:chunked. This is preventing our Netscaler load balancer from allowing the HTML generated by the JSP from being cached because it thinks it is variable content.

But if we have the max-age set, shouldn't the request still be cached regardless of the transfer-encoding?

I decided to try to get the JSP to return with fixed length (setting content-length so that way transfer-encoding would be set to fixed). . I did the following test:

Created a Jboss 4.2.3.GA web application with a test.jsp file with lots of content in it. I verified that when deployed this JSP file rendered from the server with transfer-encoding:chunked. The overall size of the content was 71.00Kb.

I went into test.jsp and tried various settings:

response.setContentLength(90000);
response.setBufferSize(90000); 

Verified test.jsp still transfer-encoding:chunked.

I also tried editing jboss-4.2.3.GA\server\default\deploy\jboss-web.deployer\server.xml and setting:

<Connector ... bufferSize="90000" socketBuffer="90000" />

Verified test.jsp is still transfer-encoding:chunked.

What am I doing wrong here? How can I get this content cached?

Was it helpful?

Solution

The problem was, I didn't have the

response.setContentLength(90000); response.setBufferSize(90000);

on the top of the page. Once I moved it, this worked.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top