1

I have css file in static resources which refer to Images folder(.zip) to apply images to css classes. The gotcha is when i replace some images from images folder, on page it still showing older image. Afterwards, i overriden css on the page only where I refred image using urlfor shows the new image.

background-image:url({!URLFOR($Resource.images,'icon_close_error.gif')}) !important;

Is there any way to solve this image cache problem?

  • Do you have cache="false" in your apex:page? – Boris Bachovski Sep 26 '14 at 6:03
  • @Bachovski Yes we already stetted this attribute – Bharat Sep 26 '14 at 6:55
  • Maybe you want to RELOAD the page instead of REFRESH. Some browsers by default do refresh (keeping the cache) and do not actually reload the page. Try see if it works by reloading your page. – Boris Bachovski Sep 26 '14 at 6:59
1

Static resource content does not support any Visualforce-style substitution such as {!URLFOR...}. If you check in your browser, you'll see that text un-replaced in the CSS file and that your page is obtaining the images from some other styling declaration.

One solution is to move that part of the CSS into a Visualforce page.

  • Thanks @keith. I have declared stylesheet on the page which using this component. This stylesheet using images from images folder. after updating images, it still showing older image. (i am not using urlfor to declare image above given example is workarround i found to load new image). I am not understanding what is the problem.. I tried with different browsers also, but no luck :( – Bharat Sep 26 '14 at 9:57
  • @Bharat I don't fully follow, but would suggest that you use your browser's "Developer Tools" to e.g. view the image URLs directly and see what you get. And generally confirm that the files in the browser are as you expect them to be. – Keith C Sep 26 '14 at 10:10
  • I have uploaded images in zip folder and my css file is out of that zip folder. is css file out of zipped file cause any issue? – Bharat Sep 26 '14 at 10:17
  • If your CSS doesn't contain Visualforce-style markup then there need not be any issue. I recommend you debug this at the client-side as mentioned in my pervious comment - the tools are very good. – Keith C Sep 26 '14 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.