Assistant automatic cache without request?

I could not find much information about this.

I want to compile all css (and js) files into the following:

css/all-c498dsfbc.css 

Now I can get only this data:

 css/all.css css/c498dsfbc.css css/all.css?v=123 

The first sucks because it has no caching at all.

The second generates a hash that can be used to iterate over the cache, but for some reason it does not change when I change something in my .css files and then run this again:

 $ php app/console assetic:dump --env=prod --no-debug 

The third sucks because I need to change the version manually, as described here: http://symfony.com/doc/current/reference/configuration/framework.html#ref-framework-assets-version . Also, I don’t think that using queries for this is a good idea (I think some browsers or CDNs may not like this). It would be much better if the file name were changed: "all-c498dsfbc.css". Here's how to do it in Rails, if I remember correctly.

Any thoughts?

EDIT

It seems that this function is missing, I can not believe in it: https://github.com/kriswallsmith/assetic/pull/190

+4
source share
2 answers

In our project, so that new content is not cached by Varnish for each deployment, we manually change the version - and the assets choose this one. I think this is a common practice. But in our case, this saves it in a folder, for example web/version-1.2.3/css/all.css .

Our configuration for the framework section:

  templating: engines: ['twig'] assets_version: %release_version% assets_version_format: "version-%%2$s/%%1$s" 
+6
source

I know this is an old thread, but it is on top of Google, so I decided it was worth the update:

Now you can do this with assetic using the cache working column . However, assetic 2.3.0 does not have a configuration for it, so you need to manually enable it now. This can be done with the following service definition:

 #config.yml or a service.yml #... services: assetic.worker.cache_buster: class: Assetic\Factory\Worker\CacheBustingWorker public: false arguments: lazy_manager: @assetic.asset_manager tags: worker_factory: { name: assetic.factory_worker } 

This work is related to a migration request for configuring a working cache user: https://github.com/symfony/AsseticBundle/pull/119/files

+1
source

All Articles