Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask {{ STATIC_URL }} giving a 304 redirect when the static directory is unspecified

Tags:

python

flask

Let's say I have a Flask application where

app = Flask(__name__, static_url_path='')

That is, {{ STATIC_URL }} == "" (empty string) and the static files are not stored under a dedicated /static directory (e.g. http://www.example.com/img/logo.png instead of http://www.example.com/static/img/logo.png)

Is it ok if I just leave it this way? The GET requests to any URL that contains {{ STATIC_URL }} give a 304 redirect instead of a 200 status code if I leave the variable in my code.

Is it necessary to:

  1. Delete all occurrences of {{ STATIC_URL }} in my templates?
  2. Create a real static directory instead of just setting it equal to an empty string?
  3. Leave all occurrences of {{ STATIC_URL }} in my templates so that I can set a new static directory in the future if necessary?
like image 740
Bill Mei Avatar asked Jul 10 '14 03:07

Bill Mei


1 Answers

HTTP response 304 is for "Redirection to a previously cached result".

This means Flask is telling your browser that it already has the content.

Clear your Browser cache and you will notice that Flask returns a 200 on your next request.

like image 132
Stephen Gornick Avatar answered Sep 24 '22 23:09

Stephen Gornick