How to clear cache folder automatically...

Asked by Delores Sanders

First, I want to say that the full rss extractor script is great and works perfectly! I am able to get the full rss feed from any website!

However, I do have one question:

My hosting company is giving me a bit of trouble because of how many files keep on generating in the cache folder. Is there a solution to this?

Is it possible to limit the amount of files in that folder.

I have thought of two solutions:
1. Just limit how many files can be in the folder. For example, only the most recent 15 files will be listed there.
2. Limit how long files can stay in that folder before that are automatically deleted.

Any solution that you great people have for me would really help out a bunch.

Thanks guys!

Question information

Language:
English Edit question
Status:
Answered
For:
Five Filters Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Keyvan (keyvan) said :
#1

Hi Delores,

Glad you like the code. :)

As for your question, the code does currently delete old files. If you have a look at lines 239 to 255: http://bazaar.launchpad.net/~keyvan/fivefilters/content-only/annotate/11/makefulltextfeed.php#L239 you'll see the cache deletion code.

Currently files older than 25 minutes are deleted when that code runs. If you have too many files building up, you could try reducing this to 10 minutes or 5 minutes by changing the $expire_time value on line 244, e.g. $expire_time = 10;

That section of code reads a lot from disk so to prevent the server doing too much work it's coded to run around 10% of the time. For your own tests you might want to have it run everytime makefulltext.php is requested. To do that, change line 242 from

if (mt_rand(0, 20) > 18) {

to

if (true) {

Hope that helps,

Keyvan

Can you help with this problem?

Provide an answer of your own, or ask Delores Sanders for more information if necessary.

To post a message you must log in.