开发者

How to keep static resource in memory in python web app?

开发者 https://www.devze.com 2023-03-09 03:59 出处:网络
I implemented a python web app, which generates images dynamically using small pi开发者_运维知识库eces of images.

I implemented a python web app, which generates images dynamically using small pi开发者_运维知识库eces of images. Each time when user visit the page, a script runs and all small images are loaded from disc to generate big image. I think loading small images from disc is quite a big overhead. Is it possible to load all small images once, and all other python scripts can use it freely whenever called?


The images will be most likely cached by the system virtual memory unless you are running out of memory. In any case, it's common practice to always run webapps behind a fast webserver and let the webserver serve static images. The webapp could simply send the img tags to the browser, than the browser would load them from the webserver


Probably the easiest way is not having your Python program quit at all. One way to accomplish this is with FastCGI: http://docs.python.org/howto/webservers.html#fastcgi-and-scgi

0

精彩评论

暂无评论...
验证码 换一张
取 消