【问题标题】:Prevent appcache cache current page防止appcache缓存当前页面
【发布时间】:2014-07-20 22:47:24
【问题描述】:

我正在尝试使用 appcache 来缓存我的大部分网页资源文件(js、css)以加快网页加载速度。但是,问题在于 appcache 也会缓存当前网页。这带来了浏览的网页不是最新的问题。如何防止 appcache 缓存当前页面,但只缓存我在清单中列出的资源?

我的清单样本:

CACHE MANIFEST
# Version 1
CACHE:
# List of resources file (JS/ CSS) path

NETWORK:
*
http://*
https://*

【问题讨论】:

标签: javascript css caching html5-appcache


【解决方案1】:

您可以做的是在 html-tag 中的 manifest-attribute 上设置一些条件逻辑,因此您无需为不想缓存的页面设置 manifest。我将其用于登录屏幕等。

例如:

<html 
<?php if(!dontCacheThisPage) echo 'manifest="yourmanifest.appcache"'; ?>
>

【讨论】:

    猜你喜欢
    • 2020-05-27
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 2013-05-18
    • 2011-11-04
    相关资源
    最近更新 更多