Closed fritzmg closed 6 years ago
cache:clear
also warms up the cache. They had deprecated it for a couple of weeks but later reverted the deprecation, so it is fine to use cache:clear
only.
There still seems to be a difference. This is the state of var/cache/prod
after cache:clear
:
annotations.map
appProdProjectContainer.php
appProdProjectContainer.php.meta
appProdProjectContainerUrlGenerator.php
appProdProjectContainerUrlGenerator.php.meta
appProdProjectContainerUrlMatcher.php
appProdProjectContainerUrlMatcher.php.meta
Container2y5l8mc/
contao/
templates.php
And this is the state of the cache after cache:warmup
:
annotations.map
+ annotations.php
appProdProjectContainer.php
appProdProjectContainer.php.meta
appProdProjectContainerUrlGenerator.php
appProdProjectContainerUrlGenerator.php.meta
appProdProjectContainerUrlMatcher.php
appProdProjectContainerUrlMatcher.php.meta
+ bundles.map
Container2y5l8mc/
contao/
+ pools/
templates.php
+ twig/
Furthermore, this is the average response time for the first request after cache:clear
on my local environment:
459.6ms
And this after cache:warmup
:
315.4ms
The latter provides an over 144ms better result.
That's interesting. Which commands exactly did you run? You should compare
cache:clear
to
cache:clear --no-warmup
cache:warmup
I've tested the following way:
rm -rf var/cache/prod
vendor/bin/contao-console cache:clear
and
rm -rf var/cache/prod
vendor/bin/contao-console cache:warmup
I did this before each request to ensure consistency. I did it 5 times for each case and took the average response time.
Note: I have used rm -rf var/cache/prod
to ensure that the cache is cleared properly (since at least under Windows errors can happen during cache:clear
due to file or operating system shenanigans). cache:clear --no-warmup
should be equal to rm -rf var/cache/prod
.
What is the content of the contao/
folder in each case?
The content of var/cache/prod/contao
is identical in each case.
Btw., when using cache:clear
, the pools
folder will be generated on the first request. However, it will have much less content than with cache:warmup
.
The twig
folder is generated with the first back end request (since the back end uses twig templates in Contao 4.5).
annotations.php
and bundles.map
will also be generated on the first request.
Hm, that does not make much sense, does it? Both cache:clear
and cache:warmup
will warm up the cache and they should not produce different results IMHO. Maybe a Symfony bug?
Can you reproduce it? May be it only occurs on Windows? I'll also try on a Linux machine.
I was actually unable to reproduce this on a Linux based shared hosting environment...
Yes I can reproduce it. But both cache:clear
and cache:warmup
execute the same warmers, so I really don't understand it.
string(67) "Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer"
string(66) "Symfony\Bundle\FrameworkBundle\CacheWarmer\TranslationsCacheWarmer"
string(60) "Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer"
string(65) "Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer"
string(62) "Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheCacheWarmer"
string(57) "Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheWarmer"
string(41) "Contao\CoreBundle\Cache\ContaoCacheWarmer"
Anyway, we should probably just re-add the cache:warmup
.
And --no-warmup
to be safe?
Yes. Basically the code from Contao 4.4.
Fixed in 77c85e2906896e55f9b76de41d0812ee6d55e7be.
In version 4.5, the
cache:warmup
was removed fromIs there any particular reason why? This leaves the website in an inefficient state after a composer operation, if you do not manually run