Placeholders and lazy building
When we set the maximum age of our Hello World salutation to 0
seconds (don’t cache), I mentioned that there are ways this can be improved in order to help performance. This involves postponing the rendering of the respective bit to the very last moment with the help of placeholders. But first, a bit of background.
Each of the cache properties we talked about can have values that make caching the render array pointless. We’ve already talked about the maximum age being set to 0
, but you can also argue that very low expiration times have the same effect. Additionally, certain cache tags can be invalidated too frequently, again making the render arrays that depend on what they represent pointless to cache. Finally, certain cache contexts can provide many variations that significantly limit the effectiveness of the cache to the point that it may even be counterproductive (due to high storage costs).
Cache tags are something very specific...