离线模式下的Chrome /打开缓存站点? [英] chrome in offline mode/open cached site?

查看:263
本文介绍了离线模式下的Chrome /打开缓存站点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用chrome的特殊kiosk解决方案,我需要在应用程序启动时使用chrome,从缓存中加载start-url,而不是尝试在线获取。

I have a special kiosk-solution with chrome where I need chrome to upon application start, load the start-url from cache, not try to fetch it online.

原因在于,正如我所说的,这是一个自助服务终端模式演示,是一个站在公众面前的屏幕,每天晚上都会重新启动,如果ISP在互联网连接上出现停机时重新启动,chrome将只显示一个错误页面。

The reason is that this is, like I said, a kiosk-mode presentation, is is a screen standing in the public that reboots every night, and if the reboot happens while the ISP has downtime on the internet connection, chrome will only show an error page.

如果我可以让它加载页面的缓存版本,而不是尝试在线获取它,那么页面的最后一个有效版本将显示,并通过我的一些漂亮的ajax工作;)它会在一段时间后自动更新。如果更新失败,则当前显示的页面版本将保留,直到后续更新成功。

If I can get it to load the cached version of the page though, instead of trying to fetch it online, then the last valid version of the page will show, and through some nifty ajax-workings of mine ;) it will automatically update after a while. If THAT update fails, the currently displayed version of the page will remain until a subsequent update succeeds.

查看我的问题?

在像Firefox这样的浏览器中,我可以通过以离线模式启动浏览器并在页面加载切换到联机模式后完成。只有FF在particulat项目中不适用于我,并且Chrome似乎没有离线模式?

In a browser like firefox I could do it by starting the browser in off-line mode and after page load switch it to online-mode. Only FF doesn't work for me in the particulat project, and Chrome doesn't seem to have an off-line mode?

推荐答案

您可以使用 HTML5离线Web应用程序来完成此操作。这可能很容易在您的案例中设置,只需在您的应用程序目录中添加如下文件:

You could use HTML5 Offline Web Applications to accomplish that. It's probably very easy to set up in your case, just add a file like the following to your app's directory:

CACHE MANIFEST
index.html
help.html
style/default.css
images/logo.png
images/backgound.png

NETWORK:
server.cgi

此清单应包含您需要显示的所有文件有用的信息,然后通过AJAX获取当前内容。还有一个NETWORK部分,您必须指定不应缓存的内容(即通过AJAX提供更新的脚本)。

This manifest should contain all the files you'll need to display some useful information and later grab current content via AJAX. There's also a NETWORK section, where you have to specify things that should not be cached (ie the script that delivers your Updates via AJAX).

您可以加载清单文件通过为标签添加清单属性( cache-manifest 是上面文件的名称):

You can load the manifest file by adding a manifest attribute to your tag (cache-manifest is the name of the file above):

<html manifest="cache-manifest">

请确保您的服务器提供MIME类型为

Make sure your server delivers the cache manifest with a MIME-type of

text/cache-manifest MIME

这篇关于离线模式下的Chrome /打开缓存站点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆