Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何在web框架中使用Appcache?_Node.js_Html_Tornado_Html5 Appcache_Offline Caching - Fatal编程技术网

Node.js 如何在web框架中使用Appcache?

Node.js 如何在web框架中使用Appcache?,node.js,html,tornado,html5-appcache,offline-caching,Node.js,Html,Tornado,Html5 Appcache,Offline Caching,我在更改主页时遇到问题,我使用了,在Tornado中,每次到达服务器时都会生成一个特殊值,它是避免xsrf攻击的标记,但当我使用.appcache文件时,问题是它会缓存所有内容!我只显示缓存静态,比如css、js、字体,下面是它包含的内容: CACHE MANIFEST # v = 2 /static/css/meteo.css /static/css/semantic.min.css /static/js/jquery-2.1.1.min.js /static/css/main.css /st

我在更改
主页
时遇到问题,我使用了,在Tornado中,每次到达服务器时都会生成一个特殊值,它是避免
xsrf攻击
的标记,但当我使用
.appcache
文件时,问题是它会缓存所有内容!我只显示缓存
静态
,比如
css、js、字体
,下面是它包含的内容:

CACHE MANIFEST
# v = 2
/static/css/meteo.css
/static/css/semantic.min.css
/static/js/jquery-2.1.1.min.js
/static/css/main.css
/static/js/semantic.min.js
/static/js/geo.js
/static/js/meteo.js
/static/fonts/icons.woff2
/static/fonts/icons.woff
/static/fonts/WeatherIcons-Regular.woff
NETWORK:
/
FALLBACK:
<!DOCTYPE HTML>
<html>
<head>
 <meta charset="utf-8">
 <title>Hack 4 Manifest</title>
</head>

<body>
  {% raw xsrf_form_html() %}
</body>
</html>
它不工作,
/
得到缓存

那么如何使用新的框架来实现这一点呢?我们不在路由中创建
html
文件,而是创建绑定到函数/类的
uri

而且,
主程序
似乎总是被缓存:

更新:,现在是

但是,你说,为什么我们不缓存HTML文件,而是缓存其余的文件。 好AppCache有一个“主条目”的概念。主条目是一个HTML文件,它在指向清单文件的HTML元素中包含一个清单属性(这是创建HTML5 appcache BTW的唯一方法)。任何这样的HTML文件都会自动添加到缓存中。这在很多时候是有道理的,但并不总是如此。特别是,当HTML文档频繁更改时,我们不希望缓存它(因为页面的旧版本很可能会像我们刚才看到的那样提供给用户)

没有办法结束吗-​​坐这个?嗯,AppCache有一个 网络白名单,指示appcache始终使用 文件的联机版本。如果我们添加我们不想要的HTML文件呢 你对这有什么看法?对不起,没有骰子。主条目中的HTML文件 缓存,即使包含在网络白名单中。明白我的意思了。 可怜的AppCache没有制定这些规则。他只是在跟踪他们 字面上他不是个笨蛋,他是个讨厌的家伙,一个十足的家伙 “工作-​​价值“

我得到了解决方案:

我制作了一个
hack.html
,其中包含:

CACHE MANIFEST
# v = 2
/static/css/meteo.css
/static/css/semantic.min.css
/static/js/jquery-2.1.1.min.js
/static/css/main.css
/static/js/semantic.min.js
/static/js/geo.js
/static/js/meteo.js
/static/fonts/icons.woff2
/static/fonts/icons.woff
/static/fonts/WeatherIcons-Regular.woff
NETWORK:
/
FALLBACK:
<!DOCTYPE HTML>
<html>
<head>
 <meta charset="utf-8">
 <title>Hack 4 Manifest</title>
</head>

<body>
  {% raw xsrf_form_html() %}
</body>
</html>
然后我使用javascript调用:

xsrf = $("iframe").contents().find("input").val()
$("#laat").html('<input id="lat" type="hidden" name="lat"></input><input type="hidden" name="_xsrf" value='+xsrf+'><input id="lon" type="hidden" name="lon"></input><input class="ui fluid massive yellow button" value="Get forecast" type="submit"/>');
xsrf=$(“iframe”).contents().find(“input”).val()
$(“#laat”).html(“”);