【问题标题】:Html read application cache to retrieve the versionHtml 读取应用程序缓存以检索版本
【发布时间】:2015-05-05 09:59:16
【问题描述】:

我们都遇到过离线缓存机制的问题。 我希望能够从应用程序缓存中打印版本。

这个数字放在清单本身的第二行,如下所示:

CACHE MANIFEST
#v19
...

我尝试使用 jquery 读取文件:

 <script>
    function showVersion()
    {
        $.get("main.appcache", function(data) {
            alert(data);
        });
    }
</script>

但是我有一个 404 : not found.

以前有人试过吗?

【问题讨论】:

  • 哎呀,我重命名了缓存文件,因为在开发过程中没有缓存。

标签: javascript jquery html browser-cache


【解决方案1】:

终于可以工作了,这段代码:

    <script>
    function showVersion()
    {
        $.get("main.appcache", function(data) {
            var lines = data.split("\n");
            alert(lines[1].substring(1));
        });
    }
    </script>

...

<a href="#/" onclick="showVersion()">Version</a>

main.appcache

CACHE MANIFEST
#v21
....

工作示例:splitons

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-04-19
    • 2017-12-08
    • 2022-11-16
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 2020-02-21
    相关资源
    最近更新 更多