title: Enabling browser caching via java
body: <p>Good day,</p>
  
  <p>I am using <a href="http://code.google.com/p/cache-filter/source/browse/tags/cachefilter-1.0.2/src/main/java/com/samaxes/cachefilter/presentation/CacheFilter.java" rel="nofollow noreferrer">CacheFilter</a> 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:</p>
  
  <pre><code>&lt;filter&gt;
      &lt;filter-name&gt;imagesCache&lt;/filter-name&gt;
      &lt;filter-class&gt;com.samaxes.cachefilter.presentation.CacheFilter&lt;/filter-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;privacy&lt;/param-name&gt;
          &lt;param-value&gt;public&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;expirationTime&lt;/param-name&gt;
          &lt;param-value&gt;2592000&lt;/param-value&gt;
      &lt;/init-param&gt;
  &lt;/filter&gt;
  
  ...
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;imagesCache&lt;/filter-name&gt;
      &lt;url-pattern&gt;/my/path/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  </code></pre>
  
  <p>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. <code>&lt;img src="..."/&gt;</code> ), it seems to hit the server all the time.</p>
  
  <p>[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.</p>
  
  <p>Additional Info:
  my path is something like /my/path?then=some&amp;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).</p>
  
  <p>Any ideas why?</p>
  
  <p>Thanks</p>