toscawidgets and cache headers

6 views
Skip to first unread message

LawrenceAfloat

unread,
Mar 5, 2009, 6:15:45 AM3/5/09
to TurboGears
All the javascript served by the toscawidgets is being delivered to
the browser with nocache in the HTTP headers. I have been trying to
see how to get the header changed to allow caching.

I found in the tosca widgets middle ware a reference to
toscawidgets.resources_expire but have failed to find how to set this
value or it fails to change the header.

I am using the AdminController REST interface to access the user
database tables and this lack of caching causes quite a performance
hit. Should the toscawidgets middleware be allowing caching of the
javascript or should I be enabling another piece of middleware to
enable caching. Or is there another suggested method - other than
serving these static files using apache etc.

Static files served from the public directory are allowing caching and
even get not changed responses.

Paul Johnston

unread,
Mar 5, 2009, 8:30:53 AM3/5/09
to TurboGears
Hi,

> Static files served from the public directory are allowing caching and
> even get not changed responses.

Yep, that's the best approach...
http://toscawidgets.org/documentation/ToscaWidgets/deploy.html

Paul

LawrenceAfloat

unread,
Mar 6, 2009, 3:22:07 AM3/6/09
to TurboGears
I did some more digging and found that the TG2 startup code does not
pass any external parameters on to toscawidgets middleware, it passes
a fixed set of parameters into toscawidgets.makemiddleware.

With a few judiscious edits I have made it pass in anything with
toscawidgets.middleware and toscawidgets.framework from the ini file
(base_config) and so passed resources_expire in to the middleware for
use in tw.core.resources.py which allready looked for a cache expiry
value. This way all the javascript files get a cache time in them. I
have done this as there is a large amount of javascript included for
the tgext.admin.AdminController (Catwalk,Rest) that makes the admin
interface very slow in development. (I am running it using paster
serve).

But on the whole very impressed with TG2 over TG1. 2 gold stars.

Edits where done in turbogears.tg.configuration.py to include relevant
config values in the values passed to tw_middleware
And in toscawidgets.tw.core.middleware.py to save expires and add to
environ during a call. If interested I will generate patch files and
post where requested.

Paul Johnston

unread,
Mar 6, 2009, 10:38:58 PM3/6/09
to TurboGears
Hi,

> Edits where done in turbogears.tg.configuration.py to include relevant
> config values in the values passed to tw_middleware
> And in toscawidgets.tw.core.middleware.py to save expires and add to
> environ during a call. If interested I will generate patch files and
> post where requested.

Patch would be great, please put a ticket on http://toscawidgets.org/trac/tw/
and drop a note to the mailing list.

> With a few judiscious edits I have made it pass in anything with
> toscawidgets.middleware and toscawidgets.framework from the ini file

Sounds good, I'll leave this to the TG guys to integrate.

Paul

Jorge Vargas

unread,
Mar 11, 2009, 2:28:01 AM3/11/09
to turbo...@googlegroups.com
On Fri, Mar 6, 2009 at 4:22 AM, LawrenceAfloat <lawrenc...@gmail.com> wrote:
>
> I did some more digging and found that the TG2 startup code does not
> pass any external parameters on to toscawidgets middleware, it passes
> a fixed set of parameters into toscawidgets.makemiddleware.
>
> With a few judiscious edits I have made it pass in anything with
> toscawidgets.middleware and toscawidgets.framework from the ini file
> (base_config) and so passed resources_expire in to the middleware for

just a little clarification they are two different places, which one
are you using? I really think this is something that should be in
app_cfg.py as it has nothing to do with deployment, if you submit a
patch I could give you a better review. (see below) but in general you
should have a function in configuration.py with default values and it
should read from app_cfg (which of course needs a patch to quickstart)

> use in tw.core.resources.py which allready looked for a cache expiry
> value. This way all the javascript files get a cache time in them. I
> have done this as there is a large amount of javascript included for
> the tgext.admin.AdminController (Catwalk,Rest) that makes the admin
> interface very slow in development. (I am running it using paster
> serve).
>
> But on the whole very impressed with TG2 over TG1. 2 gold stars.
>
Awesome, me too ;)

> Edits where done in turbogears.tg.configuration.py to include relevant
> config values in the values passed to tw_middleware
> And in toscawidgets.tw.core.middleware.py to save expires and add to
> environ during a call. If interested I will generate patch files and
> post where requested.
>
it indeed seems interesting, and as Paul said please provide a patch
in trac if you haven't done so please read
http://www.turbogears.org/2.0/docs/main/Contributing.html

LawrenceAfloat

unread,
Mar 13, 2009, 5:57:24 AM3/13/09
to TurboGears
I have created a ticket on http://trac.turbogears.org/ticket/2273

The patch files are against the current head of tg2 and tw

There are more elegant ways to achieve this but they are clear.

Jorge Vargas

unread,
Mar 14, 2009, 1:17:58 PM3/14/09
to turbo...@googlegroups.com, toscawidge...@googlegroups.com
On Fri, Mar 13, 2009 at 5:57 AM, LawrenceAfloat
<lawrenc...@gmail.com> wrote:
>
@tw people, I think that TW patch here could be applied without much troubles.

> I have created a ticket on http://trac.turbogears.org/ticket/2273
>
> The patch files are against the current head of tg2 and tw
>
> There are more elegant ways to achieve this but they are clear.

Looks goodm the TG patch could use some work (elegance as you put it)
the TW patch could be applied but I don't have (want :p) commit access
there.

Reply all
Reply to author
Forward
0 new messages