3

Does anyone know how to modify weblogic settings to set the HTTP cache header to a far future date?

For example in my current setup weblogic sets the http cache headers to expire in 5 hours (as a response of HTTP/1.1 304 Not Modified).

This is the cache header value on a .gif file ... Date: Tue, 16 Mar 2010 20:39:13 GMT.

I have re-checked and it's always 5 hours. There must be some for of settings that I can tweak to change it.

Thanks for your time!

CoolBeans
  • 20,654
  • 10
  • 86
  • 101
  • 1
    Do you have a web server in your configuration? Ideally all images should be served off the web server and not Weblogic. You can set the headers in the web server. – JoseK Mar 17 '10 at 06:47
  • No, all apps here are deployed as WAR files to weblogic unfortunately. – CoolBeans Mar 17 '10 at 16:06

2 Answers2

4

You can use this property :

    <wls:container-descriptor> 

    <wls:resource-reload-check-secs>-1</wls:resource-reload-check-secs> 

   </wls:container-descriptor> 

The element is used to perform metadata caching for cached resources that are found in the resource path in the Web application scope. This parameter identifies how often WebLogic Server checks whether a resource has been modified and if so, it reloads it.

The value -1 means metadata is cached but never checked against the disk for changes. In a production environment, this value is recommended for better performance.

Andreas Blomqvist
  • 437
  • 1
  • 9
  • 22
1

Static content is served by a weblogic.servlet.FileServlet that all web applications have by default but I couldn't find any way to configure HTTP headers. So either replace this servlet with your own servlet or use a Filter.

But the above comment is right, using a web server to serve static content is the "right" way to go: a web server does a better job at this and the application server has other things to do than serving static files.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
  • Yes I agree, but I do not have control over that. I have thought about using a filter and I guess that's the only way to do it. Thanks! – CoolBeans Mar 17 '10 at 18:18
  • @js82 You're welcome (the remark about the web server was more for the archives, I understood you don't control that). – Pascal Thivent Mar 17 '10 at 21:12
  • How about a bad workaround using HTTP META headers for Expires? Downside is this will cache your JSPs as well – JoseK Mar 18 '10 at 12:18
  • @josek Well, *I* prefer the filter approach (not really complicated and gives finer control) but it's up to the OP at the end. – Pascal Thivent Mar 18 '10 at 23:11
  • Yup I ended up using the filter process. I wish there was some config to tweak it in weblogic. Using filter here is an overkill in my opinion .. oh well! – CoolBeans Mar 29 '10 at 22:00