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.
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
rough side. And it's on our fork of the TW codebase, which requires aThe code to do that isn't to complicated, but currently a bit on the
few other dependencies (CSS parser for aggregating CSS properly) to run.
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
If you don't know how to do that by yourself, I strongly suggest to usethe 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