1

I have been trying to enable Caching for my web-page. I find-out so much post related to Caching static file in browser cache, but i did't get success.

I try for both server side or client side code for it:

SERVER SIDE

I tried to put code for set-up a "Cache-Control" header on server side page-load(write code in C#) :

DateTime dt = DateTime.Now.AddMinutes(30);
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);
HttpContext.Current.Response.Cache.SetExpires(dt);
HttpContext.Current.Response.Cache.SetMaxAge(new TimeSpan(dt.Ticks - DateTime.Now.Ticks));

Reference

CLIENT SIDE

In javascript after some googling i find a "Preloading images" technique , but applying this code also not give me correct solution of storing file into cache.

Reference

HTML META TAGS

Added following tags in my page header:

<meta http-equiv="Cache-control" content="private"/>
<meta http-equiv="EXPIRES" content="Wed, 16 oct 2013 11:12:01 GMT"/> 

did't get success.

Reference

Can any one tell me what i am doing wrong here?

And any one suggest me for perfect solution/full tutorial for enabling cache to store static files into browser cache.

Thanks in advance....!!!!

Community
  • 1
  • 1
Ishan Jain
  • 8,063
  • 9
  • 48
  • 75

2 Answers2

1

First i think you have confused caching with preloading images. If what you really need is caching, check your browser whether caching is disabled.Because scripts,images and css are cached defaultly by browser.

Next how did you check whether those are cached?

Damitha
  • 391
  • 3
  • 16
1

You could use "cache-manifest" which uses AppCache of the browser. It allows you to run your website offline also. Head to http://diveintohtml5.info/offline.html for more information. Hope it helps!!

Satpal Tanan
  • 1,108
  • 7
  • 17