I am creating a Web Application using ASP.NET MVC 3 and I would like to enable offline access to the WebPage only when the Internet is not available.
I have a question:
- I found a lot of tutorials for caching in ASP.NET MVC3 (for example Official Site) but how I can invalidate cache content if network connection is available and update cache content accordingly? Concequently, I want the user to be able to browse the online website if his internet connection is OK and browse the cached version of the website if internet connection is not available. PS. I am not sure if caching is the appropriate solution for this kind of problem.
Salamis,
I have been looking for a solution for a similar kind of problem. So far I can think of the below design to achieve what you need. I am not sure whether it is worth the pain. All the resources required for your application need to go via a Resource manager in client side. The resource manager for a given resource id, will fetch the content from the server and store it in localStorage when online and when offline would use the last fetched data from localStorage. These are easy for images as then can be stored as Data-Uri, but haven’t thought about other resources.
May be for scripts which powers these should be cached by app manifest and for data to be retrieved by service calls and images can go through the Resource manager. But I have not really found any library / framework which does the above 🙁