Skip to content

Response headers and caching #120

Answered by miguelgrinberg
Petervdburg asked this question in Q&A
Discussion options

You must be logged in to vote

I just realized that if you are using send_file() to serve your image, it wasn't easy to include a Cache-Control header. I have now added a max_age argument to send_file() that you can use to easily indicate what the cache duration is.

@app.get('/image.jpg')
def image(request):
    return send_file('/static/image.jpg', max_age=31536000)

Hope this helps!

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@Petervdburg
Comment options

Answer selected by Petervdburg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants