Cache warmers
This is a feature, used by the company I work for. Hopefully, this feature ends up in the master branch.
Steps to create a cache warmer:
- Create a service that implements
WarmerInterfaceand warms up the images (descriptions for methods can be found in the interface); - Tag it with
liip_imagine.cache.warmer. Tag also requires awarmerparameter, which contains the name of the cache warmer. It can be used in the console command (read the next point); - The console command
liip:imagine:cache:warmfinds all cache warmers and runs them, but you can also specify specific cache warmers separated by space:liip:imagine:cache:warm products_warmer brands_warmer. Runliip:imagine:cache:warm --helpto read more.
Service example:
app.products_warmer:
class: AppBundle\Imagine\ProductImagesWarmer
tags:
- { name: 'liip_imagine.cache.warmer', warmer: 'products_warmer' }
Filter example:
product_thumb_new_v2:
quality: 85
filters:
thumbnail: { size: [450, 301], mode: inset }
background: { size: [450, 301], color: '#FFFFFF' }
warmers: [products_warmer]
post_processors:
jpegoptim: {}
If the description is missing information, it is misleading or hard to understand, let me know, so I can update it.
Coverage decreased (-4.6%) to 79.099% when pulling 873c8fbf5f9ffccb801d58d635954fa45fd6a6ca on keshancs:cache-warmers-remake into 469b178413e0ee02593f0a6ba5d267463b95b0a4 on liip:2.x.
hi @keshancs , i am going through the backlog of older issues and merge requests.
thanks for the pull request. code looks good to me, but can you explain what the use case is? i would expect that usually, people keep the cached images between deployments. are you deploying image asset files that you convert with LiipImagineBundle to different sizes?
as this is a significant amount of code, i wonder if it would be better to make a separate bundle out of this. i would be happy to mention it in the documentation for people that have the same use case.