Why is GAE dev_appserver only setting ETag, but not Expires HTTP header?

569 views Asked by At

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="[email protected]: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="[email protected]: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

1

There are 1 answers

0
dragonx On

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.