croxton / Stash

Stash allows you to stash text and snippets of code for reuse throughout your templates.
GNU General Public License v3.0
197 stars 20 forks source link

Clearing cache when a Stash embed changes #88

Closed aaronbushnell closed 10 years ago

aaronbushnell commented 10 years ago

What's the best method for clearing the cache when changing a Stash embed? I'd prefer not to set stash_file_sync = TRUE on production, but I often have to for the update to show up. While I understand that Mustash can help with this, I'd like to avoid adding another step by going into the control panel.

Does a global setting like stash_file_sync_refresh = 15 // in minutes exist so the cache is cleared every 15 minutes? Or would this be a Bad Idea™?

croxton commented 10 years ago

You could add replace="yes" to the embed tag so it get's replaced every time, OR refresh="15" if you want it to rebuild every 15 minutes. That's going to add some extra processing of course, but you may not notice it unless your site is particularly busy.

Your best bet though is to clear the cache automatically when you deploy a change to the production server. That's what Mustash's API is for - you can create an end point to ping to clear the cache after you deploy.

Alternatively you could make a template that calls the tag {exp:stash:destroy ...} with the params you need, or {exp:stash:flush_cache} to clear everything (requires SuperAdmin).

aaronbushnell commented 10 years ago

Thanks, I'll check into these options!