最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - framework7 prevent caching pages data - Stack Overflow

programmeradmin1浏览0评论

i want to prevent all the app`s pages cache in Framework 7. is there any option i can add here

var myApp = new Framework7({
        material: true //enable Material theme
    })

or a function that can make me stop caching permanently.

i want to prevent all the app`s pages cache in Framework 7. is there any option i can add here

var myApp = new Framework7({
        material: true //enable Material theme
    })

or a function that can make me stop caching permanently.

Share Improve this question asked Jul 16, 2016 at 17:24 Mahmoud MabroukMahmoud Mabrouk 7333 gold badges13 silver badges31 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 6

You may set cache: false as in

var myApp = new Framework7({
    cache: false /* disable caching */
})

or (if it's fitter for your application) you may set its duration to zero setting cacheDuration: 0 as in

var myApp = new Framework7({
    cacheDuration: 0 /* set caching expire time to 0 */
})

You can refer to http://framework7.io/docs/init-app.html for more detailed specs.

for preventing cache you can use inline method (data-page attribute)

data-ignore-cache="true"

<a href="#" data-ignore-cache="true"><i class="fa fa-calendar"></i> sample link</a>

The simplest way is to define a variable timestamp and set it with Date.now() and give it to route path parameter with ?timestamp on every route path ending.

So in this case framework7 must load every html file on every browser reload again.

after your development and design is finished you can ment it out. This scenario you can use for every framework you use. it is not framework7 specific.

for examle:

var timestamp   = Date.now();

routes = [
  {
    path: '/',
    url: './index.html?'+timestamp,
  },
  {
    path: '/about/',
    url: './pages/about.html?'+timestamp,
  },
  {
    path: '/form/',
    url: './pages/form.html?'+timestamp,
  },
  {
    path: '/page-loader-template7/:user/:userId/:posts/:postId/',
    templateUrl: './pages/page-loader-template7.html?'+timestamp,
  },
  {
    path: '/page-loader-ponent/:user/:userId/:posts/:postId/',
    ponentUrl: './pages/page-loader-ponent.html?'+timestamp
  }]
发布评论

评论列表(0)

  1. 暂无评论