#1829 - Allow coding up of template dependencies

This is a spacer post for a website comment topic. The content this topic relates to: #1829 - Allow coding up of template dependencies
Making it automated would be cool.. e.g., cache a list of dependencies on compilation of a template and check all of them for modifications when the template is called. That's one more cache to deal with though lol.

Would be cool, but how do we do it for LESS? Either we'd need to hook into the lib, do our own parsing, or a regexp hack. And then, that's just for one possible inclusion method. Too much work ;). Better just to KISS and solve it with 95% okayness in much less time.
A nicer compromise might be to autodetect INCLUDE syntax, and also have wider flexibility via autodetecting any substrings like...

dep:custom.less

Could be encapsulated using whatever native comments, e.g.
/*dep:custom.less*/
{$,dep:FORM_STANDARD_END.tpl}
Done a very basic implementation for programmers, will leave this issue open in case we want to do the more sophisticated implementation.
Due to the nature of v11 JS, I have hard-coded some automatic decaching for global.js dependencies.
I made these notes on a plane, without having an Internet connection (so I could not compare to what else is written in this issue)...

New function, can_use_cache($cache_type, $file_path, $cache_path) -- implements smart_decaching (if enabled), and checks of various cache/keep_cache/cache_*/keep_cache_* parameters, and $SITE_INFO['dependency__' / dependencies_are_good stuff (recursively)
Rename disable_smart_decaching to smart_decaching, and don't have enabled by default (due to the performance hit)
Update the documentation about smart_decaching to make it clear it is not on by default, although it can be enabled via the keep_smart_decaching option
New keep_cache_off_for parameter. Any cacheable asset matching that regexp will not be cached. Implemented within can_use_cache function. Documented alongside documentation about smart_decaching
New automatic dependency detection support:
When Tempcode is parsed with the INCLUDE directive, update a .dat file, e.g. global.css.tcp.dat
Emptying the template cache (in any way) should delete the .dat files
can_use_cache function will use this data, recursively
Document alongside documentation about smart_decaching
This is all massive overkill for a relatively rare situation.

All we need is a simple keep_cache_avoid_for URL parameter that takes a regexp of what templates (etc) to temporarily not enable caching on.
Then the developer can debug using that, and when done, empty the template cache.

Meanwhile, the ability to hard-code dependencies is useful, so I've simply documented the simple implementation I've already done.
Implementing auto-detection for that would just be bloat, too much core complexity.
0 guests and 0 members have recently viewed this.