![](/img/trans.png)
[英]Google App Engine - Issue authenticating deployed version of app
[英]Caching issue when deployed flask app with SQLite on google App engine
我是谷歌云应用引擎的新手:),我正在将我的 flask web 应用程序部署到谷歌应用程序引擎,从 GAE 开始的一切看起来都很好,但是当用户访问应用程序时遇到了问题。 到目前为止对我来说似乎是一个缓存问题。(希望有人帮助我,我会发疯)
问题描述:用户从服务器端检索数据所需的任何操作。 用户必须刷新页面才能重新加载更改(这有时用户按下刷新超过 3 次。)此外,在 object ex.(table) 加载了从服务器检索的数据后,如果用户再次按下刷新页。 与采取任何操作之前一样加载的页面。 等等页面重新加载显示最新的另一个页面加载显示旧内容。
到目前为止我所做的:
我将我的 app.yaml 更新为如下:
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
default_expiration: "2s"
env_variables:
GOOGLE_APPLICATION_CREDENTIALS: 'vizionflow-5b8735ce1d20.json'
handlers:
- url: /static/css
static_dir: static/css/
expiration: '10s'
- url: /static/js
static_dir: static/js/
expiration: '5m'
error_handlers:
- file: error_nopage.html
另外,我尝试添加
@app.after_request
def add_header(r):
"""
Add headers to both force latest IE rendering engine or Chrome Frame,
and also to cache the rendered page for 10 minutes.
"""
r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
r.headers["Pragma"] = "no-cache"
r.headers["Expires"] = "0"
r.headers['Cache-Control'] = 'public, max-age=0'
return r
感谢大家即使有想法也能提供帮助:)
您是否检查过响应是否真的返回了您在 Python 中设置的标头? IIRC 它对我不起作用,因为 AppEngine 以某种方式覆盖了它们,所以我不得不在app.yaml
中设置它们,例如:
handlers:
- url: /my/route
script: auto
secure: always
http_headers:
Cache-Control: no-cache
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.