This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!
See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Invalidating image cache when using h:graphicImage

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working with an app that uses JSP 2 and JSF 1.2. There are many uses of h:graphicImage like so:
<h:graphicImage value="/img/foo.gif" />
<h:graphicImage url="#{request.contextPath}/img/bar.gif" />

The response headers tell the browser to cache the image, but there is currently no way of invalidating the cache. The workaround is to rename the images when they are change. I'd like to figure out how to patch h:graphicImage so that it can add a cache version string to the resuting <img> src attribute like this:
<img src="/img/foo.gif?cache=201011040801" />

One solution is to go through all the JSP pages and add this in, but I'm hoping for a transparent solution. My initial attempts at creating a custom renderer have failed, but here is what I was trying:



Has anyone else solved this problem with the graphicImage tag?

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic