为什么GAE dev_appserver只能设置ETag,而不能过期HTTP头? [英] Why is GAE dev_appserver only setting ETag, but not Expires HTTP header?

查看:168
本文介绍了为什么GAE dev_appserver只能设置ETag,而不能过期HTTP头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

档案&

我有以下目录结构。 b $ b |
| --- [static]
|
| --- [css]
| --- [img]
| --- [js]
| --- [app]
| - - [libs]
| --- main.js
| --- require.js



应用程序.yaml


$ b $ < app.yaml 配置 static_dir
$ b

  application:my-app-name 
版本:1
运行时:python27
api_version:1
线程安全:true

default_expiration:10d

处理程序:
- url:/favicon\.ico
static_files:static / img / favicon.ico
上传:static / img / favicon\.ico
过期时间: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
$ b $ - url:/ static / js
static_dir:static / js
expiration:15m
http_headers:
X-Static-Js-Root:Moo3
$ b - url:/ static
static_dir:static
expiration:12d
http_headers:
X-Static-ROOT:MOOOOOOOOOOO COW



HTTP Headers



/ static / css - first time < h2>

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

======================
请求标题
======= ===============
接受:text / css,* / *; q = 0.1
Accept-Charset:ISO-8859-1,utf-8; q = 0.7,*; q = 0.3
接受编码:gzip,deflate,sdch
接受语言:en-US,en; q = 0.8
连接:keep-alive
Cookie:dev_appserver_login =test@admin.com:True:113617613220115205203
DNT:1
Host:localhost:8080
Referer :http:// localhost:8080 /
User-Agent:Mozilla / 5.0(Macintosh;英特尔Mac OS X 10_8_3)AppleWebKit / 537.31(KHTML,如Gecko)Chrome / 26.0.1410.65 Safari / 537.31

=================== ===
响应头文件
======================
Cache-Control:no-cache
内容长度:103314
内容类型:text / css
日期:2013年5月6日星期一17:46:22 GMT
ETag:MTgwMTU4MDk3NA ==
过期时间: Fri,1990年1月1日00:00:00 GMT
服务器:开发/ 2.0
X-Static-Css:Moo2



/ static / css - 后续请求



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

======================
Request Headers
======================
Accept:text / css,* / *; q = 0.1
接受-Charset:ISO-8859-1,utf-8; q = 0.7,*; q = 0.3
接受编码:gzip,deflate,sdch
Accept-Language:en-US,en; q = 0.8
Cache-Control:max-age = 0
连接:keep-alive
Cookie:dev_appserver_login =test@admin.com:True:113617613220115 205203
DNT:1
Host:localhost:8080
If-None-Match:MTgwMTU4MDk3NA ==
Referer:http:// localhost:8080 /
User-Agent:Mozilla / 5.0(Macintosh;英特尔Mac OS X 10_8_3)AppleWebKit / 537.31(KHTML,如Gecko)Chrome / 26.0.1410.65 Safari / 537.31

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



问题



在初始请求中, Expires 标题设置为 Fri,1990年1月1日00:00:00 GMT 过去。

我假设它应该设置为15m未来至少基于 app.yaml



但所有后续请求只使用 ETag 获取 HTTP 304 Not Modified

Expires 标题完全缺失。 / p>

我做错了什么?



谢谢,

Soe

解决方案

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



当我使用旧的dev_appserver时,我的第一个请求正在使用正确的expires标题,但我没有设置任何额外的头文件。



虽然我没有看到304回复期满,但看起来很好。



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


File & Folder Structure

I have the following directory structure.

[app_root]
|
|---[static]
    |
    |--- [css]
    |--- [img]
    |--- [js]
         |--- [app]
         |--- [libs]
         |--- main.js
         |--- require.js

App.yaml

The app.yaml config for static_dir handlers are set to different expiration time.

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 Headers

/static/css - first time

Request URL:http://localhost:8080/static/css/bootstrap.min.css
Request Method:GET
Status Code:200 OK

======================
   Request Headers
======================
Accept:text/css,*/*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Cookie:dev_appserver_login="test@admin.com:True:113617613220115205203"
DNT:1
Host:localhost:8080
Referer:http://localhost:8080/
User-Agent: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

======================
   Response Headers
======================
Cache-Control:no-cache
Content-length:103314
Content-type:text/css
Date:Mon, 06 May 2013 17:46:22 GMT
ETag:"MTgwMTU4MDk3NA=="
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Server:Development/2.0
X-Static-Css:Moo2

/static/css - subsequent requests

Request URL:http://localhost:8080/static/css/bootstrap.min.css
Request Method:GET
Status Code:304 Not Modified

======================
   Request Headers
======================
Accept:text/css,*/*;q=0.1
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:dev_appserver_login="test@admin.com:True:113617613220115205203"
DNT:1
Host:localhost:8080
If-None-Match:"MTgwMTU4MDk3NA=="
Referer:http://localhost:8080/
User-Agent: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

======================
   Response Headers
======================
Date:Mon, 06 May 2013 17:53:20 GMT
ETag:"MTgwMTU4MDk3NA=="
Server:Development/2.0

Problem

On initial request, Expires header is set to Fri, 01 Jan 1990 00:00:00 GMT in the past.
I assume it should be set to "15m" into the future at least based on the app.yaml.

But all subsequent requests only use the ETag to get the HTTP 304 Not Modified.
The Expires header is completely missing.

Am I doing something wrong?

Thanks,
Soe

解决方案

There's something wrong with dev_appserver2. I see the same thing as you.

When I'm using the old dev_appserver, mine is working with a proper expires header on the first request, but I'm not setting any extra headers.

I don't see expire heaers on the 304 reply either though, but that seems fine.

The old dev_appserver is closer to the production behavior, but there's still some slight differences in the headers generated.

这篇关于为什么GAE dev_appserver只能设置ETag,而不能过期HTTP头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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