We make tools that make websites.

Forums (Archived)

The Solspace Support Forums are now CLOSED (read-only)

Check out our new support options here. Please refer to this blog post for more information.

   

Refreshing Template Morsels via CronJob

Rank

Total Posts: 4

Joined: Jul 10, 2008

PM

Ignore

 

Hi, I’ve looked through the documentation but I can’t see any way of using a Cronjob to automatically update the templates, we need them to be refreshed after another job has finished running as it uses an image resizer to create new images, but as the created image folder gets massive this needs to be cleared reguarly, but ofc the image resizer won’t actually run until the template morsel they are inside is refreshed.

Is there any way to tell this module to refresh all the caches automatically at a specific system time instead of just on a timer? Or preferably to be able to call the module and get it to refresh automatically from the command line on the server?

Thanks

Steven Lockey

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

Hi Steven,

From the documentation:

Refresh: Leaving this value at “0” will cause your morsel to only be refreshed by the weblog, template or category update rules listed below.
NOTE: if using this method, your morsels will only be refreshed when a user visits a template on front end of your site with the Fetch tag AND the next refresh date is due or past due.

So what I’m thinking is that you could set up refresh to “1 minute”, for example, and have your cron job ping your template containing {exp:template_morsels:fetch} every 5 minutes, for example. Since refresh time will be past at every ping, your morsels should refresh at a regular, and automatic, interval. smile

Signature

Rank

Total Posts: 4

Joined: Jul 10, 2008

PM

Ignore

 

Hi thanks for that but unfortunatly it doesn’t help the situation.

We need it to update the template at a specific time every day OR run the updates via the command-line from a cron-job. We already have it at exactly thoose settings but it does not update if the weblog, template or category hasn’t updated, which we need it to.

We can’t set the update time to 1 minute as that defeats the whole purpose of using the template morsels, which is to STOP the morsel been updated every minute due to server constraints. We need it to just update daily after the other cronjob has finished running.

Edit: Just so you have an idea of the problem, doing a refresh of all the morsels we have will run about half a million SQL commands, aka not feasile to run repeatedly throughout the day.

Avatar
RankRankRankRankRank

Total Posts: 9901

Joined: Jan 8, 2009

PM

Ignore

 

Thanks for the details. I’m trying to think of other scenarios, such as setting refresh to every 24 hours on your specific time and having the cron job right after the refresh time, but it’s a bit impractical.

Ultimately you would need a tag or some other feature where your cron job could ping a template and the morsel would get refresh right away, regardless of time or refresh interval.

This isn’t possible at the moment, but I’ll let our developers know about this feature request now. smile

Signature

RankRankRank

Total Posts: 152

Joined: Mar 9, 2010

PM

Ignore

 

The next version of Template Morsels will have the ability to refresh a morsel via CronTab.  No release date yet, but it should be in the next couple weeks.  Keep an eye on the Solspace blog or Twitter feed.

Signature