javascript - Clear Angular JS templateCache once (for each deployment) -
this issue angularjs disable partial caching on dev machine suggests using $templatecache.removeall()
clear cache templates. if want fire once upon each deployment cycle in order visitor browsers refresh/update template? our problem browsers not updating template html files, we'd end new css mixed old html. not want function fire time, defeat point of cache templates begin (right?).
per title question, what's recommended way clear $templatecache "once", example ideas i've crunched:
- does angular have internal method of detecting if template file has changed? , if "update" it.
- does angular have internal "version" or "date" compare , add conditional fire function removeall()?
- does $templatecache ever know refresh? angular creator's intentions in forcing templatecache on if html files bound change overtime , served multiple browsers.
i not want use grunt add workflow overhead happens periodically, nor chop html file templates variables. (is method template cache busting in angular?)
the alternative can see adding , removing removeall() code manually, silly.
we decided go tacking on unix timestamp version files changed file.php?v=154325232
. reason being weren't using angular templatecache, in weren't storing template data inside templatecache. thought angular automatically stores async loaded directive template files templatecache, thats not true, have explicitly use templatecache file (good tutorial on https://thinkster.io/templatecache-tutorial).
so our solution boring old versioning, understandable browser headers , non-mega-scaling websites, fine.
$modifiedts = filemtime($filename); if ($modifiedts != $lastmodificationts){ echo "$filename?v=" . time(); }
how check if file has changed?
lastly way read templatecache, its not intended save data between browser sessions rather cache service during session. has nothing browser cache, rather angular stores internally. meant websites dynamically navigate , load urls (ie: not true page refresh ajax trick) how of google websites today.
Comments
Post a Comment