Open ostark opened 6 years ago
Thanks Oliver, this looks great! It’s something along the lines of how I imagined it would work in C3, in C2 there aren’t the same events so we have to hook into the BaseTemplate
class like the core template caching does ...
The current site I’m developing this on is getting close to having its infrastructure set up so I’ll be finishing off the basic setup this week, which should give me a starting point for the cache driver interface. I’ll let you know!
The elements.onPopulateElement
event in C2 feels similar to the C3 ElementQuery::EVENT_AFTER_POPULATE_ELEMENT
event . Maybe this way you can avoid the BaseTemplate.php
core hack.
I could, and indeed went that route first, but there is no way of knowing when the template has finished parsing ... so it felt a little shaky to me. Tying in to BaseTemplate.php
means I can guarantee I have all the element IDs used in a given requests rendering cycle.
Much like you are doing in your C3 version by listening to View::EVENT_AFTER_RENDER_PAGE_TEMPLATE
I toyed around with the cache abstraction and had some ideas for structuring the config.
The Event listeners are WIP.
Is that the same direction you want to go?
Thanks for this Oliver, I like your approach.
What is your thinking behind the include/exclude routes?
I am planning on doing more work on this C2 version tomorrow / Friday so I will keep you updated with how that goes here.
I'm glad you like it :-P
Regarding incl/excl routes: I'm not sure if the config.php is the best place, but somewhere we must control cache (expire) headers. An alternative is twig.
did some refactoring at my end today: https://github.com/ostark/falcon-craft3
Hi Josh
Don't know how to start.. but what I did so far:
I played around with Craft 3 Events to collect element ids (excluding MatrixBlock elements). On the backend side I created some listeners to understand update Events.
You can simply put the event listeners in your app.php in your config folder to play around with it: https://gist.github.com/ostark/020d4dbefe71dfe107b580b80a91e8cf
Not sure if this is useful for this plugin at all as you target Craft 2.
--
Did you make any progress with the Cache driver abstraction?