【问题标题】:Why is GAE dev_appserver only setting ETag, but not Expires HTTP header?为什么 GAE dev_appserver 只设置 ETag,而不设置 Expires HTTP 标头?
【发布时间】:2013-04-30 13:14:29
【问题描述】:

文件和文件夹结构

我有以下目录结构。

[app_root] | |---[静态] | |--- [css] |--- [图片] |--- [js] |--- [应用] |--- [库] |--- main.js |--- 需要.js

App.yaml

static_dir 处理程序的 app.yaml 配置设置为不同的过期时间。

application: my-app-name
version: 1
runtime: python27
api_version: 1
threadsafe: true

default_expiration: "10d"

handlers:
- url: /favicon\.ico
  static_files: static/img/favicon.ico
  upload: static/img/favicon\.ico
  expiration: "364d"

- url: /static/img
  static_dir: static/img
  expiration: "364d"
  http_headers:
    X-Static-Img: Moo1

- url: /static/css
  static_dir: static/css
  expiration: "15m"
  http_headers:
    X-Static-Css: Moo2

- url: /static/js/app
  static_dir: static/js/app
  expiration: "15m"
  http_headers:
    X-Static-Js-App: Moo4

- url: /static/js/libs
  static_dir: static/js/libs
  expiration: "7d"
  http_headers:
    X-Static-Js-Libs: Moo5

- url: /static/js
  static_dir: static/js
  expiration: "15m"
  http_headers:
    X-Static-Js-Root: Moo3

- url: /static
  static_dir: static
  expiration: 12d
  http_headers:
    X-Static-ROOT: MOOOOOOOOOOO COW

HTTP 标头

/static/css - 第一次

请求地址:http://localhost:8080/static/css/bootstrap.min.css
请求方法:GET
状态码:200 OK

=======================
   请求标头
=======================
接受:text/css,*/*;q=0.1
接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.3
接受编码:gzip、deflate、sdch
接受语言:en-US,en;q=0.8
连接:保持活动
Cookie:dev_appserver_login="test@admin.com:True:113617613220115205203"
DNT:1
主机:本地主机:8080
参考:http://localhost:8080/
用户代理:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31

=======================
   响应标头
=======================
缓存控制:无缓存
内容长度:103314
内容类型:文本/css
日期:2013 年 5 月 6 日星期一 17:46:22 GMT
ETag:"MTgwMTU4MDk3NA=="
过期时间:1990 年 1 月 1 日星期五 00:00:00 GMT
服务器:开发/2.0
X-静态-Css:Moo2

/static/css - 后续请求

请求地址:http://localhost:8080/static/css/bootstrap.min.css
请求方法:GET
状态码:304 未修改

=======================
   请求标头
=======================
接受:text/css,*/*;q=0.1
接受字符集:ISO-8859-1,utf-8;q=0.7,*;q=0.3
接受编码:gzip、deflate、sdch
接受语言:en-US,en;q=0.8
缓存控制:max-age=0
连接:保持活动
Cookie:dev_appserver_login="test@admin.com:True:113617613220115205203"
DNT:1
主机:本地主机:8080
If-None-Match:"MTgwMTU4MDk3NA=="
参考:http://localhost:8080/
用户代理:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.65 Safari/537.31

=======================
   响应标头
=======================
日期:2013 年 5 月 6 日星期一 17:53:20 GMT
ETag:"MTgwMTU4MDk3NA=="
服务器:开发/2.0

问题

在初始请求中,Expires 标头过去设置为 Fri, 01 Jan 1990 00:00:00 GMT
我认为至少基于app.yaml,它应该设置为"15m"

但所有后续请求仅使用ETag 来获取HTTP 304 Not Modified
Expires 标头完全丢失。

我是不是做错了什么?

谢谢,

【问题讨论】:

    标签: google-app-engine app.yaml dev-appserver dev-appserver-2


    【解决方案1】:

    dev_appserver2 有问题。我和你看到的一样。

    当我使用旧的 dev_appserver 时,我的第一个请求使用了适当的 expires 标头,但我没有设置任何额外的标头。

    虽然我也没有在 304 回复中看到过期消息,但这似乎很好。

    旧的 dev_appserver 更接近生产行为,但生成的标头仍有一些细微差别。

    【讨论】:

      猜你喜欢
      • 2015-01-17
      • 1970-01-01
      • 2011-01-12
      • 2016-05-30
      • 1970-01-01
      • 2012-07-28
      • 2011-06-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多