如何在GAE中使用python进行缓存控制? [英] How to use cache-control with python in GAE?

查看:204
本文介绍了如何在GAE中使用python进行缓存控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我选择是否启用缓存标头以及它将产生的差异。
当前代码是这个,我想知道我是否应该启用缓存以及它将做什么?

I'm choosing whether to enable cache header and what difference it will make. The current code is this and I wonder whether I should enable the caching and what it will do?

#seconds_valid = 8600
#self.response.headers['Cache-Control'] = "public, max-age=%d" % seconds_valid

self.response.headers['Cache-Control'] = 'no-cache'

我可以测试一下,如果我将代码更改为这个

Can I test what the difference is if I change the code to this

seconds_valid = 8600
self.response.headers['Cache-Control'] = "public, max-age=%d" % seconds_valid

我这样做是否正确?当我启用缓存时究竟会发生什么?我仍然可以更新页面吗?

Am I doing it the right way? What exactly is going to happen when I enable the cache? Will I still be able to update the page?

谢谢

推荐答案

还有AppEngine的缓存反向代理/边缘缓存,如果给出可以拿起 Cache-Control 标头max-age 并设置为 public ,如您的示例所示。边缘缓存是尽力而为,这意味着它不会100%确定它会缓存您的响应。

There is also AppEngine's caching reverse proxy / edge cache which may pick up your Cache-Control header if given a max-age and set to public like in your example. The edge cache is "best effort", meaning it is not 100% certain it will cache your response.

可以找到更多信息此处此处

这篇关于如何在GAE中使用python进行缓存控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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