-
1. Re: Possible to attach a filter to Resource Servlet (4.1.0.Final)?
lfryc Jan 16, 2012 10:50 AM (in response to healeyb)Hi Brendan,
if files served by ResourceServlet are not getting appropriate headers setup, it's really an issue!
Could you please file a JIRA describing your issue?
Thanks,
~ Lukas
-
2. Re: Possible to attach a filter to Resource Servlet (4.1.0.Final)?
healeyb Jan 16, 2012 11:22 AM (in response to lfryc)Lukas, ok I'll log a JIRA. Glassfish (without using Tomcat) doesn't seem to do a very good job of implementing the
http protocol, basically. To workaround this I've implemented a caching filter which checks the 'date modified' of
the dates of files in the filesystem and potentially sends a 304.
The problem is that the filter is listening to Faces Servlet, but none of the RichFaces resource requests get routed
this way. What I'm seeing is that whilst richfaces resources are getting added to the browser cache (type in
about:cache in the url window), they're never used because Cache-Control is set to no-cache.
The issue is then how did it get set to no-cache? I think it's just the default setting. Regardless of this it would be
useful to have some control over these headers somehow.
-
3. Re: Possible to attach a filter to Resource Servlet (4.1.0.Final)?
lfryc Jan 16, 2012 12:02 PM (in response to healeyb)Basically all RichFaces resources served by Faces Servlet have headers set appropriately for caching.
(You can check it by removing your Filter and turning resourceMapping=false).
I assume you have problems with ResourceServlet where resources does not go through RichFaces ResourceHandler, so headers are set as for any other JSF resource - which means (AFAIK) no caching at all.
-
4. Re: Possible to attach a filter to Resource Servlet (4.1.0.Final)?
lfryc Jan 16, 2012 12:05 PM (in response to lfryc)Brendan, I have created the issue here:
-
5. Re: Possible to attach a filter to Resource Servlet (4.1.0.Final)?
healeyb Jan 16, 2012 3:19 PM (in response to lfryc)I've got this working, the key is that even though I'm using a servlet 3 container you need to manually
declare the Resource Servlet in the web.xml, even though it would auto-register without this:
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/org.richfaces.resources/*</url-pattern>
</servlet-mapping>
then you can use:
@WebFilter(filterName = "MyFilter", servletNames = {"Resource Servlet"})
In glassfish 3.1.1 I get Cache-Control: no-cache on all my richfaces resources unless I set the
response header in a filter - what I have observed is that when I set ETag & Last-Modified headers
my settings don't take effect - they're overwritten somehow.
Regards,
Brendan.