-
-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{{ nocache }} file disk storage optimization #11178
Comments
That's strange - it's working fine for me on a fresh install. Can you try deleting the |
OK, my bad I've oversimplified my example... and found out what the problem is. In my above example, I only used a main template but the problem is when using nested templates (partial). To reproduce the problem, we need 3 files : main template :
partial "experts-list" :
partial "expert" :
Given a list of 50 experts, I should get ~50 files in static-urls-cache folder with each file containing the serialization of the view var ... which I guess would be the serialized version of an expert object... so ~ 50 "small files" (given an expert object does not contains much information) First problem, related to #10835 and #10703 , the view var from the "expert" partial contains also data from the view var from the "experts-list" partial ie ... the whole "experts" array . Second "problem" (even if it's not a real bug to me but still annoying, and would be happy to have a recommanded way of handling this). In the experts-list template, we iterate over the experts collection... :
When doing this, each "anExpert" variable is "augmented" with extra information like "last" / "first" but also : "prev" and "last" ... which directly targets other experts ... themselves, having their prev and next var targeting other experts and so on... That means that when we serialize the view var in the "expert" template, we serialized not 1 expert object but many many more... Actually I have files which weight ~650ko just to serialize "one expert (and related prev / next vars)" So ~ 50 files * 650 ko = ~30mo of cache space needed. That's a lot ! Maybe adding a "warning" in the {{ nocache }} tag doc about "avoiding select whole entry objects, particularly in loop, but instead being as specific as possible" could be helpful ( I saturated a 500 go file disk in 2 days because of this ) Soooo, what I think to do here to walk around this 2nd problem, is to not select "whole" object in the nocache select tag but try pick each value explicitly... for instance doing something like this :
It's a bit cumbersome when a lot variable are needed in the nocahe tags, but it works fine. bellow an example with many variables needed in the nocache tag.
So to sum up, maybe we can have your thoughts on that, recommended best practices, and maybe close this issue if my work arround seems good enough to be documented in the nocache tag ? What do you think ? |
Bug description
I may be wrong but, I figured that using nocache tag, even with the select parameter set to restrict which variable to hydrate... the whole template context seems to be stored in the disk, which impacts performance and available disk space...
Would it be possible to also take the select parameter into account, so we can avoid caching unnecessary data.
(In my project, the static-url-cache folder can end up containing more than 100 go of files ... )
Kind of related to #9124 and #10281
How to reproduce
For instance, if you have a template like this :
In that case, a file in the statamic/static-url-cache will be created for the {{ nocache }} region, and will contain both "allProducts" and "firstProduct" serialized, even if "firstProduct" is needed ... It seems the "select" parameter optimization is only used when re-hydrateding the context from cache, but not before storing the context...
Logs
No response
Environment
Installation
Fresh statamic/statamic site via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: