Reputation: 16441
I want to set the "Expires" HTTP response header when my Glassfish server serves static resources like Javascript and image files. (because to force the browser to cache them)
How can I do this in Glassfish V 3.0.1 server?
Upvotes: 1
Views: 9557
Reputation: 1382
Are you referencing resources from secure page?? Then The answer of Jigar Joshi i.e.
http://blogs.oracle.com/cwebster/entry/caching_static_resources_in_glassfish
will not work...
If you are having secure page then following will help you out.
Static resources are not cached referenced from glassfish secure page
Upvotes: 2
Reputation: 240860
One way is using HttpServletResponseWrapper
Another approch is using filter , here is very good article :Caching static resources in glassfish
Upvotes: 2
Reputation: 13620
Glassfish uses catalina for servlet container. Extend the DefaultServlet, override something like doGet()
and add the headers you need.
http://tomcat.apache.org/tomcat-7.0-doc/api/org/apache/catalina/servlets/DefaultServlet.html
Mount your own default servlet to /
:
<servlet-mapping>
<servlet-name>mydefault</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Upvotes: 2