Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pragma caching impact on images

 
Jhun Hoon
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, i've tried using these in response object :


I know that this will 'force' the browser to request the server again, skipping the cache for the associated page. But what i dont know is this :
Are the images contained in the page also get request all over again?

Actually i just want the page to be new .. but still uses the images in the cache .. downloading all images all over again could make the web app slow ...

Plz helppppppppppp
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The images are not "contained" in the page. Only links to the images are contained in the page. So the browser makes a separate request for each image. And those headers apply only to the request for which they were returned, not to any other images.

So if your server is not setting the Pragma and Cache-Control headers on the response that sends the images, the browser will not see those headers when it downloads the images.
 
Jhun Hoon
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My old perception was that the images also got requested all over again, skipping the cache.
It all began in another case i had when i have to popup images in another window. The problem i had is that the browser still show the old image even when i'd replaced the old image in my app. So i tested the pragma and control-cache approach, and it worked, the browser 'appeared' to always load the newest images .. and thus my perception was formed

I just knew the other approaches for always fetching the newest images from server, like using dynamic parameter value in the image query string url, etc.

Maybe in my older case is that the browser got more intelligent about images after i put the pragma and control-cache in response header.

Thank you very much for the information ..
I'll just have to experiment more ..
 
Paul Clapham
Sheriff
Posts: 21316
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tested this particular situation last week. So I don't have a perception, I saw what actually happened. My browser displayed the cached versions of the images even though it was told not to cache the page linking to them.
 
Jhun Hoon
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mr.Paul !!
Exactly the point what we want right now ^__^
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic