librelist archives

« back to archive

Solving cache issues with ETag

Solving cache issues with ETag

From:
Tim Huegdon
Date:
2013-06-23 @ 14:43
Hi,

I'm building some basic CRUD functionality into a Flask app and I've
started to run into problems with browser caches following a redirect after
adding new items through handling a form POST. The items just don't appear
after the redirect; I have to refresh the page manually to see them.

To get around this, I'd like to start putting proper ETags on my responses
in the hope the browsers (in my specific case, Chrome) will update properly
following the aforementioned redirect.

Can anybody give me some pointers on this? I got a bit confused digging
into the werkzeug docs so some form of example code would be really useful.

Thanks for any help folks can give me in advance!

-- 
Tim Huegdon

http://timhuegdon.com/

Re: [flask] Solving cache issues with ETag

From:
Raj Nathani
Date:
2013-06-23 @ 16:08
Add this to the head of your html page:

<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />

Sent from my iPhone

> On Jun 23, 2013, at 10:45 AM, "Tim Huegdon" <tim.huegdon@gmail.com> wrote:
> 
> Hi,
> 
> I'm building some basic CRUD functionality into a Flask app and I've 
started to run into problems with browser caches following a redirect 
after adding new items through handling a form POST. The items just don't 
appear after the redirect; I have to refresh the page manually to see 
them.
> 
> To get around this, I'd like to start putting proper ETags on my 
responses in the hope the browsers (in my specific case, Chrome) will 
update properly following the aforementioned redirect.
> 
> Can anybody give me some pointers on this? I got a bit confused digging 
into the werkzeug docs so some form of example code would be really 
useful.
> 
> Thanks for any help folks can give me in advance!
> 
> -- 
> Tim Huegdon
> 
> http://timhuegdon.com/

Re: [flask] Solving cache issues with ETag

From:
John Hutchison
Date:
2013-06-24 @ 01:31
On Jun 23, 2013 11:10 AM, "Raj Nathani" <raj_n19@hotmail.com> wrote:
> <meta http-equiv="Cache-Control" content="no-cache, no-store,
must-revalidate" />
>

This is not standards compliant for HTML5. HTTP1.1 header objects can be
manipulated in Flask like in
http://flask.pocoo.org/snippets/100/

Just make the dict { 'CacheControl', 'no-cache' } and decorate as needed.