Page MenuHomePhabricator

Handle caching
Open, LowPublic

Description

Towards the end of app.py, there are some cache directives. Unsure of whether they are right. The issue is what the "back" button does in web browsers (e.g., whether it reloads or shows a cached version or displays a(n error?) message. It's line 314-318 on https://github.com/priyankamandikal/arowf/blob/master/app.py as follows:

No cache

@app.after_request
def add_header(response):

response.headers['Cache-Control'] = 'no-store, must-revalidate'     # do we want both no-store and must-revalidate, or only one of the two?!?
return response

Event Timeline

prnk28 created this task.Jul 18 2016, 8:38 PM
Restricted Application added subscribers: Zppix, Aklapper. · View Herald TranscriptJul 18 2016, 8:38 PM
prnk28 added a comment.Aug 1 2016, 6:12 PM

Pressing on back reloads the question because the nextrecord() function returns and subsequently displays a new question. So we will have to erase the answer for another question that was entered. For this to be removed, we have to put an autocomplete="off" attribute in the form tag. I'm verifying whether this works under all circumstances and in all browsers.

prnk28 added a comment.Aug 2 2016, 7:26 PM

I was reading up more on browser caching and it turns out there's more to it than meets the eye. After pulling the updated code to ToolLabs, I realized that autocomplete=off doesn't fix the problem on ToolLabs (it only worked locally) and it might not work on all browsers.

I found these two brilliant articles related to caching, which I think are important in understanding what's happening behind the scenes.
https://madhatted.com/2013/6/16/you-do-not-understand-browser-history
https://webkit.org/blog/427/webkit-page-cache-i-the-basics/

Now I'll try out the methods listed in these blogs and see if it works. Also, we could just refresh the page everytime 'back' button is pressed using a hidden input value that's set to 'no' and compared with the $REFRESH variable, as suggested in this post. What do you think of it? I am guessing this will override cache completely, and might in turn direct more load to the server.

@Jsalsman
PS : ToolLabs is http and not https, any immediate repercussions of that wrt to registrations and general system security?

prnk28 added a comment.Aug 3 2016, 1:27 PM

@Jsalsman did you have time to look into this?

@prnk28, not yet. I have been working on the hypothesis. If you use the
hypothesis interesting to the machine learning problem, then you will want
to log each file on f.close() instead of weekly, or maybe in addition to
weekly. I will take a look at caching after that.

Jsalsman claimed this task.Aug 5 2016, 6:03 PM
Jsalsman triaged this task as Low priority.