mirah / dubious

A Web Framework Written in Mirah for running on AppEngine
Apache License 2.0
121 stars 13 forks source link

CSS files expire in past #2

Closed hakunin closed 14 years ago

hakunin commented 14 years ago

using this approach with number in url, it is possible to cache into infinity http://michal-duby.appspot.com/stylesheets/sh_style.css?1279397780

but instead, the file sends these headers:

Cache-Control:public, max-age=600 Content-Encoding:gzip Content-Length:832 Content-Type:text/css Date:Sat, 31 Jul 2010 09:06:39 GMT ETag:"yhD_1A" Expires:Fri, 30 Jul 2010 21:11:59 GMT <-- expires in past Server:Google Frontend

woodie commented 14 years ago

Just add the desired expiration to app.yaml, these settings will propagate to appengine-web.xml

# app.yaml
static_files:
 - include: /**/*.ico
   expiration: 365d
 - include: /**/*.gif
   expiration: 365d
 - include: /**/*.jpeg
   expiration: 365d
 - include: /**/*.jpg
   expiration: 365d
 - include: /**/*.png
   expiration: 365d
 - include: /**/*.js
   expiration: 365d
 - include: /**/*.css
   expiration: 365d

# WEB-INF/appengine-web.xml 
<static-files>
  <include path='/**/*.ico' expiration='365d'/>
  <include path='/**/*.gif' expiration='365d'/>
  <include path='/**/*.jpeg' expiration='365d'/>
  <include path='/**/*.jpg' expiration='365d'/>
  <include path='/**/*.png' expiration='365d'/>
  <include path='/**/*.js' expiration='365d'/>
  <include path='/**/*.css' expiration='365d'/>
</static-files>
hakunin commented 14 years ago

Thanks for the advice.

I was trying to point out that havign expiration in past on production machine when you can set them as "never expire" seems like a bug to me.

woodie commented 14 years ago

This is much simpler than what folks need to do with Apache. We do need to be careful, we don't want other developers setting this, but then creating the links by hand.

hakunin commented 14 years ago

Thats a good point. Maybe we could copy those files that are linked properly with dubious into a directory that would get those 356d expirations? (when publishing)

woodie commented 14 years ago

I've added the changes, we should be fine. We just need to be careful to document this for new users.