Resources reloaded every-time

1 view
Skip to first unread message

Mauro Ciancio

unread,
Dec 20, 2009, 11:22:26 AM12/20/09
to ToscaWidgets-discuss
Hello everyone,

I've developed an app using TurboGears 2.0 and the admin interface
(where I do the crud stuff) it's developed with ToscaWidgets.

I'm facing an issue. In every request of the browser, all the tw's
resources
all reloaded (js and css files). This makes the app inusable.
Where should I search to change this behavior?

I've used Wireshark in order to see what was happening. The get
response
includes the following header:

'Cache-Control: max-age=0, must-revalidate, no-cache, no-store'

I guess this forces the browser to reload the js and css in every
request.

Any Ideas to change the cache control header?

Cheers
Mauro Ciancio.

Diez B. Roggisch

unread,
Dec 20, 2009, 4:47:50 PM12/20/09
to toscawidge...@googlegroups.com
Mauro Ciancio schrieb:

The real fix seems to be to have not only caching headers, but also
using an etag. With this, I created the expected 304 messages. We also
set cache-headers using a middleware-wrapper around the TW-middleware.

The code to do that isn't to complicated, but currently a bit on the
rough side. And it's on our fork of the TW codebase, which requires a
few other dependencies (CSS parser for aggregating CSS properly) to run.

So it's a bit elaborate to make it work on your side.

Another solution would be to serve the files static, through apache. You
should seriously consider that. To do so, take a look into the
documentation, there is a chapter on how to collect resources:

http://toscawidgets.org/documentation/ToscaWidgets/deploy.html

Diez

Mauro Ciancio

unread,
Dec 23, 2009, 3:53:41 PM12/23/09
to toscawidge...@googlegroups.com
Diez:


On Sun, Dec 20, 2009 at 6:47 PM, Diez B. Roggisch <de...@web.de> wrote:
The code to do that isn't to complicated, but currently a bit on the
rough side. And it's on our fork of the TW codebase, which requires a
few other dependencies (CSS parser for aggregating CSS properly) to run.

I'm going to use this approach. Could you give me some tips in order
to make this simpler?
Where is the middleware wrapper code that you told me?

Thanks in advance.
Cheers!
--
Mauro Ciancio <maurociancio at gmail dot com>

Diez B. Roggisch

unread,
Dec 24, 2009, 7:04:53 AM12/24/09
to toscawidge...@googlegroups.com
Mauro Ciancio schrieb:

> Diez:
>
> On Sun, Dec 20, 2009 at 6:47 PM, Diez B. Roggisch <de...@web.de
> <mailto:de...@web.de>> wrote:
>
> The code to do that isn't to complicated, but currently a bit on the
> rough side. And it's on our fork of the TW codebase, which requires a
> few other dependencies (CSS parser for aggregating CSS properly) to run.
>
>
> I'm going to use this approach. Could you give me some tips in order
> to make this simpler?
> Where is the middleware wrapper code that you told me?

If you don't know how to do that by yourself, I strongly suggest to use
the other option - collect the resources & serve these statically.

You can use paster for this as well, serving static resources is easily
done through the paster ini-config, like this:

[composite:main]
use = egg:Paste#urlmap
/ = mainapp
/toscawidgets = tw_static

[app:tw_static]
use = egg:Paste#static
document_root = %(here)s/your/collected/resources


[app:mainapp]
# here comes your normal TG2-main-app-config


Diez

Mauro Ciancio

unread,
Dec 24, 2009, 9:05:08 PM12/24/09
to toscawidge...@googlegroups.com
Diez:

On Thu, Dec 24, 2009 at 9:04 AM, Diez B. Roggisch <de...@web.de> wrote:
If you don't know how to do that by yourself, I strongly suggest to use
the other option - collect the resources & serve these statically.

You can use paster for this as well, serving static resources is easily
done through the paster ini-config, like this:

[composite:main]
use = egg:Paste#urlmap
/ = mainapp
/toscawidgets = tw_static

[app:tw_static]
use = egg:Paste#static
document_root = %(here)s/your/collected/resources


[app:mainapp]
# here comes your normal TG2-main-app-config

Thanks you very much. That worked great. 

Reply all
Reply to author
Forward
0 new messages