I developed a website based on Symfony 3.4 and using Webpack Encore to manage assets. When I deployed the last release, CSS/JS assets were not found:
When I inspected the source code of the web page, I saw that URLs are pointing to the old versions of the assets, like /build/app.db32012d.css
while the file manifest.json
is referencing the new versions of assets:
{
"build/app.css": "/build/app.2aba4862.css"
}
I use deployer to deploy new releases. The deployment process builds assets running yarn encore prod
.
First of all, I tried to warmup/clear the Symfony cache but still stuck.
When I browse the site in dev environement (calling app_dev.php
) the problem disapears.
I tried to restart Apache but still stuck.
I changed the DocumentRoot
of the VirtualHost from /var/www/current/web
to /var/www/foo/web
and the problem disapears until the next release.
Here is my stack:
I expect the assets URLs to be pointing to the new versions as specified in the manifest.json
file.
I suspect a cache issue somewhere but I can't find where.
I think I found the answer. Versionned assets are loaded in Twig templates using functions encore_entry_link_tags
and encore_entry_script_tags
( Official doc ). These functions read from an entrypoints.json
file that's generated by Encore to know the exact filename(s) to render. Behind theses its just PHP. As I'm using php-fpm, I have to restart service php-fpm when I deploy a new releases of my assets:
service php7.3-fpm restart
That's it!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.