0

I have a very simple python Flask app. It is just an app.py and a templates/index.html. It is deployed in Azure. The problem is that when I make changes to the index.html and re-deploy it, the browser still loads the old one although I can see the new index.html on the server. I have tried Azure Web App Service stop/start to no success.

Any ideas how to fix this?

Walid
  • 43
  • 1
  • 6
  • Can you be more clear where you deployed it and how? Azure App Services, Static Web Apps, etc. – Julian Hüppauff Sep 25 '22 at 10:32
  • Yes, it is an Azure Web App Service. It was deployed automatically since it is connected to github for auto-deployment. Once I committed the change to the index.html file, a deployment was initiated and completed successfully. – Walid Sep 25 '22 at 10:51
  • If the Answer below doesn't solve your problem. Can you please also post your deployment pipeline. – Julian Hüppauff Sep 26 '22 at 07:48
  • @JulianHüppauff I found a solution by following the instructions in the answer to [this question](https://stackoverflow.com/questions/65321862/azure-web-app-deployed-to-tmp-folder-instead-of-wwwroot) although my case is not exactly the same. – Walid Sep 27 '22 at 15:53

1 Answers1

0

The file is probably still cached by your browser. Try to reload the site without cache (Different for every browser and OS - shift+f5 windows, cmd+r mac etc., ...).

You can set an HTTP-Header to control how long files are cached. I'd recommend using the @app.after_request decorator.

@app.after_request
def add_header(response):
    response.cache_control.max_age = 300  # set this to 0 to force a reload every time
    return response

I hope that helps. If not, please provide a little bit more code.

bitflip
  • 3,436
  • 1
  • 3
  • 22
  • Thanks @bitflip for your suggestion. It did not work for me as the problem was Azure issue. I tried a workaround suggested in [this question](https://stackoverflow.com/questions/65321862/azure-web-app-deployed-to-tmp-folder-instead-of-wwwroot) and that fixed the issue for me. – Walid Sep 27 '22 at 15:55