Is there any way to clear the site cache from within a snippet?
This would be a great thing for those who use both caching AND the NewsPublisher snippet.
-
MODX Staff
- 12,272 Posts
The page the Newspublisher snippet resides on should not be cached. "Articles" it creates can be cached. At least I can’t think of any reason they can’t be.
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
-
☆ A M B ☆
- 24,524 Posts
Create a snippet that deletes the cache files from the assets/cache folder. The emptyCache() function from the manager/processors/cache_sync.class.processor.php file could be modified slightly to do the job; it even keeps track of how many and which files are deleted for making a report. Of special interest is the preg_match() line.
-
MODX Staff
- 12,272 Posts
Or include your menu snippet so it won’t be cached: [!snippetName!]
Ryan Thrash, MODX Co-Founder
Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
Not that you’ve asked a bad question, but if your host is so slow that having snippets uncached makes wait time unbearable, you would probably be better off with a new host. With today’s technology, caching snippets shouldn’t make a serious difference unless you have thousands of them on a page or something.
Just one mans opinion.
Standard Disclaimer
I could be totally wrong.
Quote from: Mark at Sep 12, 2005, 05:42 PM...In regard to the caching uncaching speed differance, when a page with about 5 snippets is cached its total php time (mysql will be 0 because of full caching) is about 0.1-0.3 seconds. With caching disabled pages take up to 3-5 seconds generation time.
Well yeah. Then I’d be caching too! Glad you found a solution.
Standard Disclaimer
I could be totally wrong.