N
N
nano_e_t_42016-09-06 20:52:43
Nginx
nano_e_t_4, 2016-09-06 20:52:43

How to cache pictures?

Hello everyone
. I have a site on flask, where the user in the web selects a link with the name of the image and transfers it to the get_file page, where the image itself and meta-information on it are displayed. Since some pictures weigh quite a lot, I want to cache them
. Question - how to cache them? Now I'm doing caching in flask, but I want to learn how to do this also using nginx. Please indicate the links where such an experience is described (I believe that there are a lot of them on the Internet, I can’t really figure out how to set the search correctly), or tell me how to do it.
In practice, I use the nginx-uwsgi-flask bundle
Thank you!
Correction:
the user selects a link with the image name:
that is, there is an index.html page. It displays the get_file.html?foto={{foto_name}} links. Clicking on the link displays the get_file page with the specified photo and its metadata

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pcdesign, 2016-09-06
@pcdesign

Nevertheless, nginx should give the statics, and flask should do other things.
Everything is simple in ngix.
Specify the path and time of caching, for example:

root   /home/flask/app/;
expires 30d;

And you give the picture from the template, with a direct path.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question