skip to Main Content

I have a flask app running on Linux and working correctly under firefox.
For chrome, it only works if the cache is disabled!?
But i want my website to work correctly without every user having to disable caching.

This is how the template HTML header looks:

<!-- Bootstrap & CSS  -->
<link rel="stylesheet" type="text/css" href="/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/fontawesome-free-6.1.1-web/css/all.min.css" >
<link rel="stylesheet" type="text/css" href="/css/app.css">

{% if css_file %}
<link rel="stylesheet" type="text/css" href="{{ css_file }}">
{% endif %}

<!-- JQuery -->
<link rel="stylesheet" type="text/css" href="/bootstrap/css/jquery-ui.css" >
<link rel="stylesheet" type="text/css" href="/bootstrap/css/jquery-ui.min.css" >
<script type="text/javascript" src="/bootstrap/js/jquery.js"></script>
<script type="text/javascript" src="/bootstrap/js/jquery-ui.min.js"></script>

<!-- Bootstrap JS -->
<script type="text/javascript" src="/bootstrap/js/bootstrap.min.js"></script>

<!-- local JS -->
<script type="text/javascript" src="/scripts/language.js"></script>
{% if js_file %}
<script type="text/javascript" src="{{ js_file }}"></script>
{% endif %}

And yes all files exist in the static folder (because it works in firefox)
And flask is initiated like this (which is the default):

# create and configure the app
app = Flask(__name__, static_url_path='', static_folder='static', template_folder='templates')

Chrome (dev tools->network):
enter image description here

Chrome (dev tools->network)(with cache disabled), same for firefox (cache enabled):
enter image description here

Could someone give me a hint on how to analyse further what the problem is?
Could it be related to the response of flask for static files?
Or do I have the wrong header order?
Or is it a problem with the scripts/ stylesheets, do they have the wrong configuration?
So the question is how to fix this for chrome without disabling the cache.

And no I do not have Adblock or similar addons installed.

2

Answers


  1. I think this issue related to Chrome, but I don’t have time to dig deeper into it. My workaround is include no-store in Cache-Control header:

    @app.after_request
    def add_header(response):
        response.headers['Cache-Control'] = 'no-cache, no-store'
    
    Login or Signup to reply.
  2. It’s a bit late but had the same issue and it got fixed by upgrading flask, you can check what needs to be upgraded with

    pip list --outdated
    

    if you have multiple outdated packages (this will upgrade everything)

    pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search