开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜