Forums

Page reload sometimes loads old data

My user submits a street address, gets back a list of elected officials. Sometimes a page reload shows officials from a previous run. Cache is turned off in meta tags. <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> <meta http-equiv="Pragma" content="no-cache" /> <meta http-equiv="Expires" content="0" /> I can't reproduce this behavior in my dev environment (my laptop).

Also, sometimes the app shows previous results and I can see from debug print statements that the app has made the proper SQL queries and fetched the correct results.

Is the page rendered on server or is frontend code calling backend for data?

Not sure I understand. There are two HTML/Jinja2 pages. First takes user's street address, passes it to a Flask route which passes it to an SQLite DB, gets the return data (which is always correct) and then does a return render_template to the results page.

I've done 2 other things since yesterday. One is on the results page I just keep reloading the page. The reload of course does not invoke the backend Python code. About the third try I get data from some previous request.

I downloaded a Brave browser to be sure I had a browser that had never made any previous requests. Then I made 1 request, got the right data. Reload, right data, reload - data from some previous request that of course had never been made by this browser.

And, as I said, I cannot make this happen on my dev environment.

That sounds like you need to read this: https://help.pythonanywhere.com/pages/GlobalStateAndWebApps/

That worked, got me thinking along the right lines. Fixed now, thanks.

Glad to hear that!