changing client side caching headers expires or cache-control value

65 views
Skip to first unread message

molhokwai

unread,
Oct 16, 2013, 11:14:24 AM10/16/13
to web...@googlegroups.com
Hi,

I've tried changing client side caching headers expires or cache-control value (from 10mns by default?), running the code below from the corresponding controller, but the values are unaffected.

        import datetime
        expires
= datetime.datetime.now()+datetime.timedelta(0,365*24*3600)
       
# ex: Fri, 01 Jan 1990 00:00:00 GMT
        response
.headers['Expires'] = expires.strftime("%a, %d %b %Y %H:%M:%S GMT")
        response
.headers['Cache-Control'] = 'public,max-age:%i,must-revalidate' % (365*24*3600)


How should this be done?

Thanks
-molhokwai

molhokwai

unread,
Oct 16, 2013, 2:06:23 PM10/16/13
to web...@googlegroups.com
Well...
It doesn't seem to work on  local dev_appserver, but it actually works, when deployed on appspot.com...
So, anyway, problem solved...

Thanks



--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/BMxhOL_X2y8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
-------------------------------------------------------------------------------------------------------------
MT, Molhokwai
+32 489 33 71 51, molh...@gmail.com, chat/voip(gtalk):molhokwai

Don DeLillo: Underworld |  Don DeLillo: Cosmopolis | The Matrix: The Architect | Brandford Marsalis: Mr J.C. 
(Live) | Ursula K. LeGuin: The Dispossessed | Annares | Robert Zemeckis: Contact |  What the *bleep* do we 
know... | E.J. Strickland: In this Day | Jeff Buckley: Grace | Qawalis | Genesis: FoxTrot | XXX | Artémise & 
Mausole | XXX | Le Taj Mahal | Slow | Infinity | Khalasa | Google | Coltrane | X-Men III: The Phoenix | RATM | 
Jean D'ormesson: Le Juif Errant | Les Quatre Incommensurables | Edgar Allan Poe: Ms found in a bottle | 7 | 
Georges Clooney: Confession of a dangerous Mind | The hand of God | Dreaming Bear Kanaan | 
Implementing change | Amin Maalouf: Le Rocher de Tanios | 9 | The Grand Cycle | The Beyonder | The 
Venus Project | Patrick Suskind: Le Parfum | Ethan & Lucas Vorly | Khaili Gibran: On Love | 
Urbanfarming.org | Planck's Constant | Gemineye: Poetic bloodline | Moving-planet.org | 350.org | Bree 
Olson | Jacques Audiard: Sur mes lèvres | Raymond Devos | Terrence Mc Kenna | Alan Watts | Mindwalk:
 Liv Ullman's Sophia Hoffman | ...
Let's talk

Dave S

unread,
Oct 16, 2013, 8:25:45 PM10/16/13
to web...@googlegroups.com


On Wednesday, October 16, 2013 11:06:23 AM UTC-7, molhokwai wrote:
Well...
It doesn't seem to work on  local dev_appserver, but it actually works, when deployed on appspot.com...
So, anyway, problem solved...


Different IP or domain name?

If your browser's cache wasn't cleared, the old copies would be retained until the original expiration had passed, so you wouldn't see the new copies.  By changing "machines", you may have been unrecognized as "already cached".

I learned a little about this stuff in connection with the Web2Py IDE ("blank screen in editor")
 
 /dps

molhokwai

unread,
Oct 17, 2013, 2:26:43 AM10/17/13
to web...@googlegroups.com

Cleared the cache to be sure and retried...
Getting '304 Not Modified' status code for local static items to be cached
But '200 (from cache)' for remote items...

So seems like this has to do with localhost requesting local resources...
Client side caching works perfectly online, so not an issue, but good to know...

Thanks
-molhokwai
Reply all
Reply to author
Forward
0 new messages