Max-age less than specified in app.yaml

257 views
Skip to first unread message

Anders

unread,
Nov 14, 2008, 2:38:38 AM11/14/08
to Google App Engine
When the expiration attribute is set in the app.yaml file then the
Cache-Control header still has a max age of 600 seconds.

For example expiration 1 day in app.yaml:

- url: /static/images
static_dir: static
expiration: "1d"

Will result in the response:

Date: Fri, 14 Nov 2008 07:25:34 GMT
Expires: Fri, 14 Nov 2008 07:35:34 GMT
Cache-Control: public, max-age=600
Content-Type: image/gif
Server: Google Frontend
Content-Length: 760
Connection: Close

Shouldn't the correct max-age for Cache-Control in this case be 86400
(number of seconds in 1 day)?

Jesaja Everling

unread,
Nov 14, 2008, 10:50:35 AM11/14/08
to google-a...@googlegroups.com
Hello Anders,

maybe this thread helps?

http://groups.google.com/group/google-appengine/browse_thread/thread/bcdacfaac673181a

Best Regards,

Jesaja Everling

2008/11/14 Anders <in...@blabline.com>:

--
o
L_/
OL
This is Schäuble. Copy Schäuble into your signature to help him on his
way to Überwachungsstaat.

Marzia Niccolai

unread,
Nov 14, 2008, 2:23:15 PM11/14/08
to google-a...@googlegroups.com
Hi Anders,

This is strange, because it should set *both* the Expires and the Cache-Control header to be 1 day, and both are wrong.

I attempted to replicate this on one of my applications, but so far have not been able to (for me it's setting both headers correctly).

Could you send along your complete app.yaml file and the specific URL on which you are seeing this issue?

Thanks,
Marzia

Anders

unread,
Nov 14, 2008, 10:03:18 PM11/14/08
to Google App Engine
Hi Marzia,

The complete app.yaml file looks like:

application: blab
version: 1
runtime: python
api_version: 1

handlers:

- url: /robots.txt
static_files: static/files/robots.txt
upload: static/files/robots.txt

- url: /sitemap.xml
static_files: static/files/sitemap.xml
upload: static/files/sitemap.xml

- url: /favicon.ico
static_files: static/images/favicon.ico
upload: static/images/favicon.ico

- url: /static
static_dir: static

- url: /static/images
static_dir: static
expiration: "1d"

- url: /.*
script: blab.py

And the URL I tested is:

http://www.blabline.com/static/images/default_avatar.gif

Maybe it's because the parent directory /static is not set to
expiration 1 day? I only want one day expiration for the /static/
images directory, not for the entire parent directory.

On Nov 14, 8:23 pm, Marzia Niccolai <ma...@google.com> wrote:
> Hi Anders,
>
> This is strange, because it should set *both* the Expires and the
> Cache-Control header to be 1 day, and both are wrong.
>
> I attempted to replicate this on one of my applications, but so far have not
> been able to (for me it's setting both headers correctly).
>
> Could you send along your complete app.yaml file and the specific URL on
> which you are seeing this issue?
>
> Thanks,
> Marzia
>

David Symonds

unread,
Nov 14, 2008, 11:08:22 PM11/14/08
to google-a...@googlegroups.com
On Sat, Nov 15, 2008 at 2:03 PM, Anders <in...@blabline.com> wrote:

> - url: /static
> static_dir: static
>
> - url: /static/images
> static_dir: static
> expiration: "1d"

Try swapping the order of these two. I believe they are scanned in
order, and the first match is used.


Dave.

Anders

unread,
Nov 14, 2008, 11:15:19 PM11/14/08
to Google App Engine
Hi Jesaja,

The thread you posted talks about a bug about "expiration" not working
in the SDK, but I guess it will work in the Google App Engine since it
worked for Marzia. I will try to put the images in a separate
directory instead of as a subdirectory in under /static, something
like:

- url: /images
static_dir: static
expiration: "1d"

- url: /static
static_dir: static


On Nov 14, 4:50 pm, "Jesaja Everling" <jeverl...@gmail.com> wrote:
> Hello Anders,
>
> maybe this thread helps?
>
> http://groups.google.com/group/google-appengine/browse_thread/thread/...
>
> Best Regards,
>
> Jesaja Everling
>
> 2008/11/14 Anders <i...@blabline.com>:

Anders

unread,
Nov 15, 2008, 12:16:59 AM11/15/08
to Google App Engine
Now it's working:

Date: Sat, 15 Nov 2008 05:01:45 GMT
Expires: Sun, 16 Nov 2008 05:01:45 GMT
Cache-Control: public, max-age=86400
Content-Type: image/gif
Server: Google Frontend
Content-Length: 760
Connection: Close

I moved the images to a separate directory:

- url: /images
static_dir: images
expiration: "1d"

I also noticed an embarrassing error I had made:

- url: /images
static_dir: static
expiration: "1d"

Should be:

- url: /images
static_dir: static/images
expiration: "1d"

And maybe it will work if this declaration is moved before the /static
declaration:

- url: /static/images
static_dir: static/images
expiration: "1d"

- url: /static
static_dir: static

On the other hand, I think it can be good to have images in a separate
directory.

Anders

unread,
Nov 15, 2008, 1:39:09 AM11/15/08
to Google App Engine
Now I have changed it to:

- url: /images
static_dir: static/images
expiration: "1d"

- url: /static
static_dir: static

Which works fine.

Anders

unread,
Nov 15, 2008, 3:43:34 AM11/15/08
to Google App Engine
Yes you are right, the documentation says: "Patterns are evaluated in
the order they appear in the app.yaml, from top to bottom. The first
mapping whose pattern matches the URL is the one used to handle the
request."

http://code.google.com/appengine/docs/configuringanapp.html

I also made a mistake in the declaration where static_dir: static
should be static_dir: static/images

On Nov 15, 5:08 am, "David Symonds" <dsymo...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages