0

I have one windows azure web site. In my website I have some images that loads every time. I tried using code : background-image : url(/Design/img/save-btn.jpg); and as i have multiple images it takes time to load all images and wasting bandwidth. I want to first save images on users computer cache and from next time images will be display from the user computer cache till user didn't clear the cache.

Indranil.Bharambe
  • 1,462
  • 3
  • 14
  • 25

1 Answers1

1

Images are static content, and usually did not pass from asp.net to add them headers programmatically for the cache.

You can do that, set the static content cache, on the IIS settings. You can also use the web.config to give instructions to IIS as:

<configuration>
  <system.webServer>
    <staticContent>
        <clientCache cacheControlMaxAge ="8.00:00:00" cacheControlMode="UseMaxAge" />
    </staticContent>
  </system.webServer>
</configuration>

Some more q/a to read about:
- What are difference between IIS (Dynamic and Static) cache,OutPutCache and browser cache
- IIS and Static content?

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • its on windows azure. i didnt get iis on it. i just upload package on windows azure. – Indranil.Bharambe Nov 27 '13 at 06:45
  • Test web.config, probably can do the same job, behind azure must be an iis server anyway. – Aristos Nov 27 '13 at 06:46
  • i have web.config sir but in azure we have to set background with the background-image : url(/Design/img/save-btn.jpg);. so each time it download. without background-image : url(/Design/img/save-btn.jpg); we cannot assign image in azure. – Indranil.Bharambe Nov 27 '13 at 06:48
  • i was added that content in web.config but it didnt work. as i have multi instance servers – Indranil.Bharambe Nov 27 '13 at 06:49
  • @Terror.Blade You can also check this http://www.iis.net/configreference/system.webserver/staticcontent/clientcache - – Aristos Nov 27 '13 at 06:52
  • @Terror.Blade This is the solution, to set the static content headers. If you check the images headers and did not see the headers, then you just need to locate the reason of it - why you can not set that headers. - can you give me a test url to check that out ? – Aristos Nov 27 '13 at 06:53
  • i will make it and give it to you – Indranil.Bharambe Nov 27 '13 at 07:36