简体   繁体   中英

how to HTML5 APPLICATION-CACHE with asp.net MVC4 for offline web-app?

I understand the app cache in html5 with static contents and with normal file extension, for example: index.html, theme.css, app.js

The question is how to do app cache it with MVC4 for web-app?? The data is dynamic where comes from api and set-to localStorage.

I want to cache the files *.cshtml (app-template) for using offline.

 CACHE MANIFEST
# 2012-02-21 v1.0.0

CACHE
/theme.css     *<-- Understand*
/logo.gif
/main.js    
/home/index.cshtml       *<-- is this correct?* 
/sales/dashboard.cshtml    *<--  is this correct?*
/_Answer_below                *<-- please help this

NETWORK:
/config.html

 FALLBACK:
 /html/ /offline.html

example.com/home
route to
=> A). example.com/home/index.cshtml

or B). example.com/home/index.html

or C). example.com/home/index

Application cache should specify client URIs, so the one you have on B or C is valid depending on how you set up routing in your mvc app

CACHE
/theme.css     *<-- Understand*
/logo.gif
/main.js    
/home/index       
/sales/dashboard    

cshtml files are server side templatates, which are renered on server, so there is no reason to cache them on the client. Rendered views on the opposite is the one you will cache

Alternative approach is to use some client side mvc framework, like knockout, angular etc, or just some handlebars templates and cache thouse instead of rendered view, together with some data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM