Reputation: 9831
To support client side templating I've created a set of endpoints with li3 (Lithium - PHP framework) where hitting the URL as normal returns a static render (HTML type). Adding .json to the end of the path will render the content as JSON and exclude the document (, & ) from the response and the "shell" which is basically common HTML like the header and footer UI.
This all works fine, so for the home page the static render is:
/
And for a render using templates, merge:
/home.json
/shell/headerfooter.json
/document.json
On the client side I can then take these templates and merge them together without issue.
What I'd like to do for data efficiency is be able to create a revisioning hash on each of these templates and the most obvious approach is to get a "snapshot" of the generated output for "/home.json", "/shell/headerfooter.json" and "/document.json", but I can't see where / how to do this.
The use case is caching these templates in a service worker and only updating them when a change has occured, which can be easily achieved with '/home.123.json' etc.
Does anyone know how in a lithium controller I could magically say:
$documentOutput = li3::render('/document.json')
Upvotes: 0
Views: 69
Reputation: 5770
If I understand your question correctly, you can leverage the browser's cache using E-Tags, like this: http://li3.me/docs/book/manual/1.x/common-tasks/etags
Upvotes: 0