-
1. Re: Richfaces Cache-Control settings, need 'public'
ilya_shaikovsky Apr 15, 2010 2:57 AM (in response to blueheronhollow)please check this issue comments. https://jira.jboss.org/jira/browse/RF-7452
Also, please do not leave comments in different places in order not to search where we answered
-
2. Re: Richfaces Cache-Control settings, need 'public'
blueheronhollow Apr 15, 2010 10:14 AM (in response to ilya_shaikovsky)Hi,
Thanks for the reply, and sorry for the cross posts.
I did check the issue comments, but they don't apply in this case, as I'm not using Tomcat for authentication, and in fact the Pragma header is not present.
I think there should be an option to include 'public' in the Cache-Control header, since without it browsers will not cache files over ssl. In my case tomcat isn't in ssl mode, it's running on the regular 8080 port, talking to httpd over the ajp protocol, and http is handle all the ssl computations.
public void sendHeaders(ResourceContext context) {boolean cached = context.isCacheEnabled() && isCacheable(context);if (log.isDebugEnabled()) {log.debug(Messages.getMessage(Messages.SET_RESPONSE_HEADERS_INFO,getKey()));}// context.setHeader("Content-Type",getContentType());context.setContentType(getContentType(context));Date lastModified = getLastModified(context);if (lastModified != null) {context.setDateHeader("Last-Modified", lastModified.getTime());}int contentLength = getContentLength(context);if (cached) {if (contentLength > 0) {context.setContentLength(contentLength);}long expired = getExpired(context);if (expired < 0) {expired = DEFAULT_EXPIRE;}context.setDateHeader("Expires", System.currentTimeMillis() + expired);context.setHeader("Cache-control", "public, max-age=" + (expired / 1000L)); <--- I've modified this line to add public, which fixes the issue} else {if (contentLength > 0) {context.setContentLength(contentLength);// } else {// context.setHeader("Transfer-Encoding", "chunked");}context.setHeader("Cache-control", "max-age=0, no-store, no-cache");context.setHeader("Pragma", "no-cache");context.setIntHeader("Expires", 0);}}For now I think I will pull the js and css files from the RichFaces jars and serve them from apache directly, unless somebody has a better workaround, as I'd like to avoid compiling a custom version of RichFaces.Should I open a Jira issue for inclusion of a 'public' option for the Cache-Control header?Thanks,Ian -
3. Re: Richfaces Cache-Control settings, need 'public'
blueheronhollow Apr 15, 2010 10:18 AM (in response to blueheronhollow)Well, that didn't paste properly, although it looked fine while editing:
The line that I have to change in order for caching to work correctly is:
context.setHeader("Cache-control", "public, max-age=" + (expired / 1000L));With this, Firefox and IE will correctly cache static files over ssl. -
4. Re: Richfaces Cache-Control settings, need 'public'
igor_ti Sep 4, 2010 7:06 AM (in response to blueheronhollow)Hi Ian,
I am having the same problem, I need to do the caching of Richfaces resources over HTTPS and to do that Richfaces needed to add the "public" directrix on Cache-Control header.
Ian Have you opened the JIRA issue for this problem? Ilya Shaikovsky should we do that?
I'll really patch Richfaces on my own, because we have a application that will process millions of requests/day on a huge national network (115.000 workstations); and this application need's to run under https.
-
5. Re: Richfaces Cache-Control settings, need 'public'
igor_ti Sep 8, 2010 6:24 AM (in response to igor_ti)I think the reason for "public" parameter was not well explained by me. So...
Without the "public" parameter on Cache-control header tag, under a HTTPS connection, the browser will NOT perform disk cache, this is important because that means that every time my user restart the browser and come into my web application all of my Richfaces resources's will be sent to him again, that way no matters what I set on "org.ajax4jsf.DEFAULT_EXPIRE" context parameter, the maximum time for the cache will be determined by the browser restart.
With the "public" parameter the browser will do the disk cache and if I want that the Richfaces resources be cached for 6 months, they will be.
-
6. Re: Richfaces Cache-Control settings, need 'public'
igor_ti Sep 16, 2010 6:34 AM (in response to ilya_shaikovsky)Ilya,
I have created this issue on JIRA, about this feature request: