本文介绍了GAE:使用webapp2启用边缘缓存(Python)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

YouTube上有这个新视频展示了GAE架构中EdgeCaching的优势,并且在视频中的这个特定时刻,他们演示了如何轻松利用这些视频:



不幸的是,这并不容易... ...

我正在寻找使用Google提供的webapp2框架来实现边缘缓存。



我在打电话:

  self.response.pragma = 'Public'
self.response.cache_expires(300)

但似乎被某些东西



我得到的头文件是:

  HTTP / 1.1 200 OK 
Pragma:Public
Cache-Control:max-age = 300,no-cache
过期时间:2013年2月23日星期六19:15:11 GMT
Content-Type :application / json; charset = utf-8
内容编码:gzip
X-AppEngine-Estimated-CPM-US-Dollars:$ 0.000085
X-AppEngine-Resource-Usage:ms = 39 cpu_ms = 64
日期:2013年2月23日星期六19:10:11 GMT
Pragma:no-cache
过期时间:1990年1月1日星期五00:00:00 GMT
Cache-Control: no-cache,must-revalidate
Vary:Accept-Encoding
服务器:Google Frontend
Content-Length:600

我使用ndb顶层:

  app = ndb.toplevel( webapp2.WSGIApplication(... 

我尝试了这里解释的技术,但它们似乎并不适用于webapp2:


我也看了这篇文章:



我试图手动设置所有内容,但没有成功。有些东西正在覆盖我的缓存设置。



有没有办法让webapp2工作?任何其他选项是受欢迎的。



编辑:我使用版本前缀的网址:,这可能是我的问题。



  self.response.cache_control ='解决方案

public'
self.response.cache_control.max_age = 300


There has been this new video on youtube demonstrating the strength of EdgeCaching in the GAE architecture, and at this particular point in the video they demonstrate how easy it is to leverage:http://www.youtube.com/watch?v=QJp6hmASstQ#t=11m12

Unfortunately it's not that easy...

I'm looking to enable edge caching using the webapp2 framework provided by Google.

I'm calling:

self.response.pragma = 'Public'
self.response.cache_expires(300)

but it seems overridden by something else.

The header I get is:

HTTP/1.1 200 OK
Pragma: Public
Cache-Control: max-age=300, no-cache
Expires: Sat, 23 Feb 2013 19:15:11 GMT
Content-Type: application/json; charset=utf-8
Content-Encoding: gzip
X-AppEngine-Estimated-CPM-US-Dollars: $0.000085
X-AppEngine-Resource-Usage: ms=39 cpu_ms=64
Date: Sat, 23 Feb 2013 19:10:11 GMT
Pragma: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Cache-Control: no-cache, must-revalidate
Vary: Accept-Encoding
Server: Google Frontend
Content-Length: 600

I'm using ndb top level:

app = ndb.toplevel(webapp2.WSGIApplication(...

I tried the technics explained here, but they don't seem to apply to webapp2:http://code.google.com/p/googleappengine/issues/detail?id=2258#c14

I also looked at this post too:https://groups.google.com/d/topic/webapp2/NmHXoZZSVvo/discussion

I tried to set everything manually with no success. Something is overriding my cache settings.

Is there a way to make it work with webapp2? Any other option is welcome.

EDIT: I'm using an url with version prefix: http://version.appname.appspot.com and it's probably the cause of my problem.

解决方案

This should be all you need:

self.response.cache_control = 'public'
self.response.cache_control.max_age = 300

这篇关于GAE:使用webapp2启用边缘缓存(Python)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 16:49