how to cache django javascript message file ('/jsi18n/') with apache (production setup)

478 vues
Accéder directement au premier message non lu

alain D.

non lue,
5 mars 2008, 12:58:5705/03/2008
à Django users
Hi,

If there a simple apache configuration that is know to make browser
cache the javascript message file ('jsi18n') in a standard apache
django production setup ?
I've tried to add :

<Location "/jsi18n/">
ExpiresActive on
ExpiresDefault "access plus 1 month"
</Location>

To my django virtual host and then I get this headers in the reply :
HTTP/1.1 200 OK
Date: Wed, 05 Mar 2008 17:54:25 GMT
Server: Apache
Vary: Accept-Language,Cookie,Accept-Encoding
Content-Type: text/javascript
Content-Language: en-us
Cache-Control: max-age=2592000
Expires: Fri, 04 Apr 2008 17:54:25 GMT
Connection: close

But my browser (firefox) keeps requesting this file for every
(html) request that includes it ...

Any idea ? Help ?

Regards,

Alan

jfine

non lue,
5 mars 2008, 17:33:5305/03/2008
à Django users
On Mar 5, 5:58 pm, "alain D." <alain.delieu...@free.fr> wrote:
> Hi,
>
> If there a simple apache configuration that is know to make browser
> cache the javascript message file ('jsi18n') in a standard apache
> django production setup ?

[snip]

> To my django virtual host and then I get this headers in the reply :
> HTTP/1.1 200 OK
> Date: Wed, 05 Mar 2008 17:54:25 GMT
> Server: Apache
> Vary: Accept-Language,Cookie,Accept-Encoding

Thank you for sending clear and precise information. I think the
problem lies with the Vary: header. Are you sure you want to tell the
cache that the javascript depends on the cookie?

Hope this help.
--
Jonathan

Malcolm Tredinnick

non lue,
5 mars 2008, 18:21:0805/03/2008
à django...@googlegroups.com

It has to depend on the localisation cookie. The jsi18n URL is mapped to
the django.views.i18n.javascript_catalog view. This produces a file
containing the translation strings for the requester's currently active
language. Since the currently active language can be stored in the
language cookie, the cache for that URL must depend vary on "cookie".

This is fairly tricky to work around, since web pages need a single URL
they can refer to in order to pull in the translation file, regardless
of the user's active language choice for that particular request.

Short version: it's pretty much impossible to cache that file directly.

I have a couple of ideas to try and experiment with in the future, but
it's not the highest priority item at the moment.

Regards,
Malcolm

--
Borrow from a pessimist - they don't expect it back.
http://www.pointy-stick.com/blog/

alain D.

non lue,
6 mars 2008, 05:56:0206/03/2008
à Django users
Thanks for the precise reply ... looking forward to know about your
ideas on this matter ...

wtanaka.com

non lue,
26 août 2009, 10:25:2826/08/2009
à alain D.,django...@googlegroups.com
This is a wrapper function and some instructions for enabling caching
of the /jsi18n/ javascript string catalog: http://wtanaka.com/django/jsi18ncache
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message