【发布时间】:2015-10-04 17:38:08
【问题描述】:
我使用Privoxy 或Proxomitron 将自定义Javascript标签注入网站,然后从本地python服务器(在localhost:8888上)加载脚本:
... <script type="text/javascript"
src="http://localhost:8888/tweakscript.js"
></script></body>
其中一些脚本标签是巨大的第三方 javascript 库,它们也存储在我的计算机上。它们永远不会改变,但每次都会重新加载。我想缓存它们。
我尝试了这些标题,但没有成功:
HTTP/1.1 200 OK
Content-type: text/javascript; charset=UTF-8
Vary: Accept-Encoding
Date: Sun, 04 Oct 2015 03:24:14 GMT # the current date
Last-Modified: Fri, 02 Oct 2015 06:34:40 GMT # never changes
Expires: Fri, 01 Apr 2016 03:24:14 GMT # one month in future
Cache-Control: public, max-age=15552000 # cache for one year
Access-Control-Allow-Origin: * # Content Security Policy
Access-Control-Allow-Methods: GET, POST, OPTIONS
Connection: close
(javascript code here)
如何让浏览器缓存这些文件?
【问题讨论】:
标签: python-3.x localhost http-caching