0

文件和文件夹结构

我有以下目录结构。

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

应用程序.yaml

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

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过去。
我认为它应该"15m"至少基于app.yaml.

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

难道我做错了什么?

谢谢,

4

1 回答 1

2

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

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

不过,我也没有在 304 回复中看到过期的听众,但这似乎很好。

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

于 2013-05-07T16:48:50.280 回答