0

I am using HTML5 cache manifest to build to be able to load some ASP.NET pages (text and images) even without internet connection.

I have data stored on a database and would like to access this data when connection is available and add the image names which I have in my records to the cache manifest file so that they can be cached and accessed when offline. Images will always reside in the same folder but the contents (images) of this folder will change when people add or remove images from the server via CMS.

I am using asp.net and c#. How can I do this please? Is there a way to actually add the image names programatically to the cache manifest file and then refresh it? Can I cache the entire folder? What is the simplest please?

Thanks, Jean

JeanPaul Galea
  • 113
  • 3
  • 11

1 Answers1

0

Yes. Generate the cache manifest the same way you'd generate any other dynamic page on your site. Scan the directory for the files and output them into the manifest.

However, since the browser will attempt to download everything in the manifest every time the manifest is updated you'll have to be a bit careful to set appropriate expiry headers so that the clients will not have to repeatedly download images they will never actually look at.

If images are going to get added to this folder every minute or so, or less often but the images are large, then the appcache approach isn't going to work out very well for them. Then you'd probably be better off setting up a fallback image which indicates the file isn't cached.

robertc
  • 74,533
  • 18
  • 193
  • 177
  • robertc, I greatly appreciate your answer and will give it a shot...the only problem I have is that (being a bit of a noob) I cannot seem to understand how to actually output the file names into the manifest...is there some sort of cache.add(imagename) of some sort please? and do I do it from c# or javascript? thank you again ;) – JeanPaul Galea Jan 30 '13 at 19:24
  • @JeanPaulGalea Create the manifest file *with* an .aspx page. – robertc Jan 30 '13 at 19:27
  • @ robertc...so I can actually create a file from the code-behind and assign any content I like to it? then I name it 'cache.manifest' and use that as my cache manifest? – JeanPaul Galea Jan 30 '13 at 19:34
  • YEP! Exactly what I had to do...thanks robertc you're a life saver man ;) – JeanPaul Galea Jan 31 '13 at 07:37