python - Django caching - can it be done pre-emptively? -


I have a detox view, which receives part of my data from the external website, which is the URL of urllib2 / BeautifulSoup Parsing using. / P>

This operation is expensive, so I cache ~ 5 minutes using the low-level cache API. However, after the cached data expires, every user who arrives at the site will get significant delays of seconds to go to the external site to parse the new data.

Is there any way to load a new data, the data is dull, so that no user will ever give this type of delay? Or is it indispensable?

Please note that I am on a shared hosting server, so keep this in mind with your answers.

Edit: Thanks for the help so far though, I'm still not sure how I will complete this with Python script , Which I will call I had shown a basic test that the demo cache is not global, which means that I tell it from an external script, the cache data is being run in this framework. suggestion?

Edit another: It's coming to think, this is probably because I'm still using local memory cache. I suspect that if I move the cash to the memcatch, db, whatever, then it will be solved.

So do you want to schedule some time to run at a regular interval? At the expense of some CPU time, you can use.

Alternatively, if you can use it, then for every 5 minutes:

  * / 5 * * * * / path / to / project / Refresh_cache.py  

For cPanel, use the Cron Manager to provide different ways to set up web host in. For Google App Engine, use For all of this, you have to do refresh_cache.py before.

By the way, answering a user's request is considered lazy caching. This is a pre-mounted caching and do not forget to cache enough time to rebuild the page!


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -