title: Python Flask Not Updating Images
body: <p>There were a few Flask questions about images on here, but none that addressed my issue.  I have an app that creates an image, saves it, then displays it.  Once.  It SHOULD do this multiple times (each time the image is changed it SHOULD load a new image).  It does not; it only displays the first image associated with the filename it displayed.  These files are no longer in the static folder, yet show up in the app.</p>
  
  <p>Image is created, saved to a subfolder of the static folder via:</p>
  
  <pre><code>img.save('../source/static/images/characters/{}.png'
                .format(self.char.name), "PNG")
  </code></pre>
  
  <p>The app loads it thru:</p>
  
  <pre><code>'&lt;img src="/static/images/characters/{}.png" '
              .format(self.name) +
              ' alt="{}" title="{}" '.format(self.name, self.name) +
              'width=100% /&gt;'
  </code></pre>
  
  <p>(which is added to the flask app thru code manipulations).</p>
  
  <p>Issue is I have two test cases: One where text appears on the image (text being added was removed a few iterations of the code ago) and one where the alpha channel is in the wrong place (RGBA -> ARGB issues, resolved, except I can't see the new files on the site).  As of now, only running/testing locally.  The proper pictures appear in  <code>~\source\static\images\characters</code>.  All *.py files are in source.  What do I need to do in order to fix this?</p>
  
  <p>I've tried:</p>
  
  <pre><code>@app.after_request
  def add_header(response):
  """
  Add headers to both force latest IE rendering engine or Chrome Frame,
  and also to cache the rendered page for 10 minutes.
  """
  response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
  response.headers['Cache-Control'] = 'public, max-age=0'
  return response
  </code></pre>
  
  <p>as a separate piece of code at the end of my <code>app.py</code> file, also tried adding:</p>
  
  <pre><code>app.config["CACHE_TYPE"] = "null"
  </code></pre>
  
  <p>To the beginning of the <code>app.route()</code> that calls the page that creates the image.</p>
  
  <p>On a likely separate note, the image should be in a table, but appears to not be...  What I mean is, there is a table with headers, then a table in one col, the image in the other... but the first column's text is below the image (though each in their proper places otherwise).  Bizarre, but likely unrelated.</p>
  
  <p>So, why does flask not update properly, and how do I force it to do so?  (Problem persists when shutting the program down and reopening it).</p>
  
  <p><strong>UPDATE:</strong>
  This <em>seemed</em> to work...</p>
  
  <p><a href="https://stackoverflow.com/questions/23112316/using-flask-how-do-i-modify-the-cache-control-header-for-all-output">Using Flask, how do I modify the Cache-Control header for ALL output?</a></p>
  
  <p>Did it by adding:</p>
  
  <pre><code>app = Flask(__name__)
  app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 1
  </code></pre>
  
  <p>To the top (included the app = Flask part to help other newbs) and this at the end:</p>
  
  <pre><code># No caching at all for API endpoints.
  @app.after_request
  def add_header(response):
      # response.cache_control.no_store = True
      if 'Cache-Control' not in response.headers:
          response.headers['Cache-Control'] = 'no-store'
      return response
  </code></pre>
  
  <p><em>But only worked for a single instance</em>, others still had weird caching.  Could be cached from before and the other one had just timed out, but that shouldn't happen since I keep closing the server (localhost), right?</p>