framework7 防止缓存页面数据

framework7 prevent caching pages data

我想阻止 Framework 7 中所有应用程序的页面缓存。我可以在此处添加任何选项吗

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

或者可以让我永久停止缓存的功能。

您可以设置 cache: false

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

或者(如果它更适合您的应用程序)您可以将其持续时间设置为零设置 cacheDuration: 0,如

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

您可以参考http://framework7.io/docs/init-app.html了解更详细的规格。

最简单的方法是定义一个变量时间戳并用 Date.now() 设置它,并在每个路由路径结束时用 ?timestamp 将其传递给路由路径参数。

所以在这种情况下,framework7 必须在每次重新加载浏览器时加载每个 html 文件。

开发设计完成后可以注释掉。您可以将此场景用于您使用的每个框架。它不是 framework7 特定的。

例如:

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-component/:user/:userId/:posts/:postId/',
    componentUrl: './pages/page-loader-component.html?'+timestamp
  }]

为了防止缓存,您可以使用内联方法(数据页属性)

data-ignore-cache="true"

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