For some high traffic sites the DRUPALFILES/css/css_....css and js files get pretty out of hand, not deleting often enough. Here is a patch to delete all cache files from css and js directory if they are older than 1 hour.

Let me know if you have any questions or see room for improvement.

CommentFileSizeAuthor
cleaner-filedeletion.patch2.57 KBnicholas.alipaz

Comments

nancydru’s picture

Status: Needs review » Fixed

Committed to 6.x-1.x-dev. Thank you very much for the patch.

nicholas.alipaz’s picture

Thanks for the commit. I think this part could be easily altered to do a specified time period rather than just hardcoding an hour. I am not sure what else would really need configuring. Let me know if you think of anything and I would be glad to make a patch for it.

nancydru’s picture

The only thing I can think of is maybe some extra granularity to clearing Watchdog (see #570964: Log clear function).

nancydru’s picture

Actually, I just thought of one other thing, if you want to try it. Instead of always testing if the last cron was more than xxx ago, why not change the variable from "last_run" to "next_run" and then expose that time, so an admin can say "Run it at 4 minutes past the hour" by inputting the time to next run it. But this should be a new issue.

nicholas.alipaz’s picture

NancyDru, do your suggestions pertain to the settings I added for deletion of cached files? If they do, then I am not sure I am following you. If they regard the module in general then I think I get a vague idea as to what you are describing.

I guess I am just a little confused since my question was regarding extra configuration options for the patch I submitted, not really the module as a whole.

My patch has:
+function cleaner_delete_files($ext, $seconds = 3600) {
Which should probably have some sort of administration option for configuring the time period (something other than 3600). We wouldn't really even need to do any math on it, just put something in the description saying "If the options to delete cached JS/CSS files are checked then please be sure to input the amount of time in seconds to retain cached files, the default is 3600 (1 hour)."

nicholas.alipaz’s picture

nicholas.alipaz’s picture

One last note. Google actually has a built in calculator. Just type something like:
convert 2 hours to seconds
and it will give you the answer at the top of the page.
http://www.google.com/search?hl=en&safe=off&client=firefox-a&rls=com.ubu...

nancydru’s picture

It's hard to believe that anyone really needs a web calculator to convert hours to seconds, but I guess there are some people who love their ignorance.

I was suggesting an option to set the age of the CSS and JS files, but also some other things for the module, not so much as to your changes.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.