Flask only updates after clear browsing history

Asked

Viewed 175 times

1

I am developing a site for study purposes with flask, only I need to clear the browser history whenever I make any changes to my css, I am doing this because the browsers (Chrome, edge and Mozilla already tested) continue displaying the previous version of css even if I restart the flask server.

These are my logs when updating the page without clearing the history:

MEUIP**** - - [06/Sep/2019 15:19:51] "[37mGET / HTTP/1.1[0m" 200 -
MEUIP**** - - [06/Sep/2019 15:19:53] "[37mGET / HTTP/1.1[0m" 200 -
MEUIP**** - - [06/Sep/2019 15:19:56] "[37mGET / HTTP/1.1[0m" 200 -

These are the logs when I clear the history:

MEUIP**** - - [06/Sep/2019 15:20:09] "[37mGET /static/css/home.css HTTP/1.1[0m" 200 -
MEUIP**** - - [06/Sep/2019 15:20:09] "[37mGET /static/images/web_icon.png HTTP/1.1[0m" 200 -

What I noticed is that the application only goes after my static files when I clear the browser history, I think this problem is related to flask being more specific still the problem is how I am using flask, follows my code in the hope of finding a solution to the problem :

home py.:

from flask import Flask, render_template, url_for

app = Flask(__name__)

@app.route('/', methods = ['GET', 'POST'])
def home():
    return render_template('home.html')

if __name__ == '__main__':
    app.run(port=minhaporta, debug=True)

home html.:

<head>
    <meta charset="utf-8">
    <title>Image Lab</title>
    <link rel="icon" href="{{url_for('static', filename='images/web_icon.png')}}">
    <link rel="stylesheet" href="{{url_for('static', filename='css/home.css')}}">
    <h1>Image Lab</h1>
</head>

<body>
    <nav>
        <ul>
            <li><a href="https://google.com">Homea</a></li>
            <li><a href="https://google.com">Teste</a></li>
            <li><a href="https://google.com">Teste2</a></li>
        </ul>
    </nav>
</body>

home css.:

h1 { font-size: 80px; text-align: center; }
ul { list-style-type: none; margin: 500; padding: 20; }
li { display: inline;}

Note: I’m just having this problem with the static files the other parts of the code are being updated immediately without the need to clear the history.

  • 1

    I tried to replicate your error but failed, check with another browser or request directly via Curl to see if the error persists.

1 answer

0


Not quite the solution but it was enough to get around my problem, update the page with:

SHIFT+F5.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.