金字塔网络框架的新兴缓存挖掘
pyramid_cachebust的Python项目详细描述
#金字塔形恶病质
通过查询字符串参数对静态资产进行缓冲。
安装
通过PIP:
PIP安装金字塔
设置
通过“include”方法添加到配置程序:
配置=配置程序()
配置包含(“金字塔缓存”
配置添加静态视图('static','myapp:static')
现在,“pyramid.request.request”有两个新方法:“cachebusted”路径和“cachebusted”url。这些方法是“request.static_path”和“request.static_url”的包装器,添加了对破坏缓存的查询参数的标记:
request.cachebusted_path('myapp:static/file.css')
>>gt;'/static/file.css?_=394A82FDD72EED3AC45D113BD8AF554E'
request.cachebusted_url('myapp:static/file.css')
>;>gt;'http://localhost/static/file.css?_=394A82FDD72EED3AC45D113BD8AF554E'
查询字符串是通过两种方式之一生成的默认值是文件内容的md5 hexdigest。这两个选项是文件的mtime('mtime')或app init('init')的时间。每个资产生成一次mtime的哈希/查找结果被缓存,并在结果调用时提供服务。
配置
放置在金字塔`.ini`:
名称|类型|默认|说明
-
cachebust.enabled bool true打开/关闭插件
| cachebust.reload|u files | bool | false |如果为true,则忽略缓存并根据每个请求计算查询参数
cachebust.method str md5文件计算方法(md5、mtime或init)
| cachebust.param| key | str | | key查询参数
贡献者
感谢您的贡献:
*理查德·迈萨诺(迈萨诺)
*马吕斯·格德米纳斯(mgedmin)
通过查询字符串参数对静态资产进行缓冲。
安装
通过PIP:
PIP安装金字塔
设置
通过“include”方法添加到配置程序:
配置=配置程序()
配置包含(“金字塔缓存”
配置添加静态视图('static','myapp:static')
现在,“pyramid.request.request”有两个新方法:“cachebusted”路径和“cachebusted”url。这些方法是“request.static_path”和“request.static_url”的包装器,添加了对破坏缓存的查询参数的标记:
request.cachebusted_path('myapp:static/file.css')
>>gt;'/static/file.css?_=394A82FDD72EED3AC45D113BD8AF554E'
request.cachebusted_url('myapp:static/file.css')
>;>gt;'http://localhost/static/file.css?_=394A82FDD72EED3AC45D113BD8AF554E'
查询字符串是通过两种方式之一生成的默认值是文件内容的md5 hexdigest。这两个选项是文件的mtime('mtime')或app init('init')的时间。每个资产生成一次mtime的哈希/查找结果被缓存,并在结果调用时提供服务。
配置
放置在金字塔`.ini`:
名称|类型|默认|说明
-
cachebust.enabled bool true打开/关闭插件
| cachebust.reload|u files | bool | false |如果为true,则忽略缓存并根据每个请求计算查询参数
cachebust.method str md5文件计算方法(md5、mtime或init)
| cachebust.param| key | str | | key查询参数
贡献者
感谢您的贡献:
*理查德·迈萨诺(迈萨诺)
*马吕斯·格德米纳斯(mgedmin)