Mantis - Resin
Viewing Issue Advanced Details
6064 minor always 06-22-17 06:15 07-12-17 16:27
stbu  
ferg  
normal  
closed 4.0.53  
no change required  
none    
none  
0006064: Proxy-Cache: "Cache-Control: max-age" Header disappears when (conditional) Redirect Rule is present in web-app
We're running Resin-Professional in an environment with multiple virtual hosts, several web-apps and many Rewrite Rules.

While trying to add HTTP Caching configuration again to certain web-apps we have observed a problem that when a Rewrite Rule was present, the Cache-Control: max-age=nnn" header was removed.

It was possible to make a simple test web-app with one .png image that should be cached. Resin will add the proper Header when <proxy-cache> and <cache-mapping> is configured, but once a conditional rewrite rule has been added, it's gone.

The Additional information contains further desriptions on how to reproduce the issue.
Steps to reproduce:

- Downloaded Resin Professional 4.0.53
- cd into resin-pro-4.0.53
- Copy our Pro license into resin-pro-4.0.53/licenses
- Added the following line into resin.xml to add the <proxy-cache> within the <cluster id="app">

Here is the diff between the new resin.xml and the original one:
84,86d83
<
< <proxy-cache path="cache-test" memory-size="256M" disk-size="2G" entries="16384" max-entry-size="2M" enable="true" enable-range="true"/>
<

drop test.war (uploaded to this bug-report) into resin-pro-4.0.53/webapps

Run curl on command line to see the headers of a request to the test web-app's /images/logo.png file:

curl -o /dev/null -s -D - http://localhost:8080/test/images/logo.png [^]

HTTP/1.1 200 OK
Server: Resin/4.0.53
ETag: "409sQeD44+m"
Last-Modified: Thu, 22 Jun 2017 12:27:22 GMT
Accept-Ranges: bytes
Cache-Control: max-age=666
Content-Type: image/png
Content-Length: 5964
Date: Thu, 22 Jun 2017 12:34:39 GMT

==> As you can see there is the "Cache-Control: max-age=666" header returned by Caucho Resin 4.0.53


Now, let's make a simple change in the resin-pro-4.0.53/webapps/test/resin-web.xml file and add the following Redirect Rule (just uncomment it in the file)


  <resin:Redirect regexp="^/" target="http://example.com/"> [^]
    <resin:IfCookie name="DummyIsNotSet"/>
  </resin:Redirect>


Restart Resin or the Web-App and then run curl again:

curl -o /dev/null -s -D - http://localhost:8080/test/images/logo.png [^]

HTTP/1.1 200 OK
Server: Resin/4.0.53
Cache-Control: private
ETag: "409sQeD44+m"
Last-Modified: Thu, 22 Jun 2017 12:27:22 GMT
Accept-Ranges: bytes
Content-Type: image/png
Content-Length: 5964
Date: Thu, 22 Jun 2017 12:47:35 GMT

==> Now, the "Cache-Control: max-age=666" is gone, but the "Cache-Control: private". But this is not enough without either "Expire" or "Cache-Control: max-age".
But the resin-web.xml still contains the "<cache-mapping url-pattern="/*.png" max-age="666"/>" and the Rewrite has not fired.
 test.war [^] (7,074 bytes) 06-22-17 06:15

Notes
(0006770)
ferg   
07-12-17 16:27   
This is normal behavior.

The URL output varies depending on the Cookie header, because of the resin:IfCookie. So, the output can't be cached publicly without a Vary header. (It is cached internally.)

You can enable the public caching headers with a resin:SetVary rule.

  <resin:SetVary regexp="..." value="Cookie"/>