Updating static files: Still in browser cache

1,612 views
Skip to first unread message

Thomas Guettler

unread,
Jun 9, 2011, 3:09:06 AM6/9/11
to Django users
Hi,

My static files (JS/CSS) are cached in the browser. But if there is a bug
in a file, an update won't help people which have already cached the old file.

You would need a new URL for every change in the JS/CSS files.

How do you handle this?

Thomas

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

Alexey Moskvin

unread,
Jun 9, 2011, 3:13:07 AM6/9/11
to Django users
Tomas, try this: https://github.com/jaddison/django-cachebuster

On 9 июн, 11:09, Thomas Guettler <h...@tbz-pariv.de> wrote:
> Hi,
>
> My static files (JS/CSS) are cached in the browser. But if there is a bug
> in a file, an update won't help people which have already cached the old file.
>
> You would need a new URL for every change in the JS/CSS files.
>
> How do you handle this?
>
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/

Malcolm Box

unread,
Jun 9, 2011, 9:16:11 AM6/9/11
to django...@googlegroups.com
On 9 June 2011 08:09, Thomas Guettler <h...@tbz-pariv.de> wrote:
My static files (JS/CSS) are cached in the browser. But if there is a bug
in a file, an update won't help people which have already cached the old file.

You would need a new URL for every change in the JS/CSS files.


Version all static assets, bump the version when you change them.

Malcolm

DrBloodmoney

unread,
Jun 9, 2011, 9:21:53 AM6/9/11
to django...@googlegroups.com

I keep the file name the same and append a querystring eg.
/static/js/mycustom.js?v=1001 then just increment the querystring on
versioning.

Martin

unread,
Jun 9, 2011, 10:27:37 AM6/9/11
to django...@googlegroups.com
Use django-compressor.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Malcolm Box

unread,
Jun 9, 2011, 1:18:25 PM6/9/11
to django...@googlegroups.com, django...@googlegroups.com

Sent from my iPhone, please excuse any typos

That works but may bust intermediate caches. Some won't cache anything with a query string.

Malcolm

Thomas Guettler

unread,
Jun 10, 2011, 9:54:01 AM6/10/11
to django...@googlegroups.com

Hi Malcolm,

which application does not cache URLs with a query string? I think most do, or am I wrong?

Malcolm Box

unread,
Jun 10, 2011, 1:38:19 PM6/10/11
to django...@googlegroups.com
On 10 June 2011 14:54, Thomas Guettler <h...@tbz-pariv.de> wrote:
On 09.06.2011 19:18, Malcolm Box wrote:
> On 9 Jun 2011, at 14:21, DrBloodmoney <drbloo...@gmail.com> wrote:
>
>> On Thu, Jun 9, 2011 at 9:16 AM, Malcolm Box <malco...@gmail.com> wrote:
>>> On 9 June 2011 08:09, Thomas Guettler <h...@tbz-pariv.de> wrote:
which application does not cache URLs with a query string? I think most do, or am I wrong?Malcolm Box

http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/

Squid for one (at least in some configurations). There are no doubt others.

First rule of caching: there will always be a totally borked cache between you and your users.

Malcolm
Reply all
Reply to author
Forward
0 new messages