Enabling browser caching via java
- by Franz See
Good day,
I am using CacheFilter to filter a certain path to my server (which outputs an image stream to the response stream). And I've configured it in my web.xml as follows:
<filter>
<filter-name>imagesCache</filter-name>
<filter-class>com.samaxes.cachefilter.presentation.CacheFilter</filter-class>
<init-param>
<param-name>privacy</param-name>
<param-value>public</param-value>
</init-param>
<init-param>
<param-name>expirationTime</param-name>
<param-value>2592000</param-value>
</init-param>
</filter>
...
<filter-mapping>
<filter-name>imagesCache</filter-name>
<url-pattern>/my/path/*</url-pattern>
</filter-mapping>
Using my firefox, if I access my url via the address bar, it hits the server the first time but uses the cache during succeeding calls. However, if the url is inside my page ( i.e. <img src="..."/> ), it seems to hit the server all the time.
[EDIT] After a few more testing, accessing my image via the address bar does not work all the time. But caching does seem to work more often with it than . As to whether it really, I am not sure.
Additional Info:
my path is something like /my/path?then=some&query=strings. Notice that it doesn't have an extension (i.e. gif, png, jpeg ) but it's mimetype is set properly ( image/gif, image/png, image/jpeg ). I am not sure if the lack of extension or the presence of the query strings have any impact. (Also, another note. though my url have query strings, I am using the same uri + query string over and over again with my tests).
Any ideas why?
Thanks