-
Notifications
You must be signed in to change notification settings - Fork 227
Added the support of the CacheBustingWorker #119
Conversation
+1 for enabled by default. I think it adheres to the principle of least surprise better than the current behaviour, things just work in a cache aggressive environment. For other cases it works just the same. |
+1 for going with CacheBusting by default. Front end developers will love it! |
Does it affects development too ? (when assets aren't dumped on disk). If the filename changes with content, that may break javascript debuggers. |
@arnaud-lb I haven't checked the javascript debuggers, but I have checked that it does not break the routing when using the controller. and if you don't want it in development, you would still be able to disable it in |
+1 for being on by default - agree it's the path of least surprise, and is so beneficial I think it can't not be default. |
I'm having several issues after enabling it which didn't occur before. Though, I'm not sure if I'm doing something wrong here. With an empty cache (not warmed up), I'm getting For prod env, even with a warmed-up cache and dumped assets, assets seem to be re-dumped when accessing their URLs. In the end, my assets didn't work at all and I reverted to the old behavior. Is there a known trap I just fell into? If not, I'd rather keep this feature disabled by default until it's working reliably. |
@craue For the prod environment, assets are never dumped on the fly. they should not even be served by a controller. So I don't understand how you could have them being re-dumped when accessing the file. and for the other issue, it has nothing to do with AsseticBundle. It looks like a proxy generated by JMSAopBundle |
@stof: Indeed. According to my config, they aren't served by a controller. But I noticed Java being run to invoke the YUI Compressor. I admit it's pretty strange... As long as I could even explicitly disable this feature, I'm also fine with enabling it by default. |
+1 For enabling this by default |
I like this feature, and we need it. |
@liuggio it would simply mean you have to run |
We currently use different web servers and only one cdn bucket. If we run |
@liuggio when using the |
thanks a lot for the explanation, 👍 without doubt |
works nicely! +1 for merging this :) |
Tried the |
Why this PR isn't merged yet ? :'( ping @stof |
Been using this for a few days - anyone else noticing that using the content strategy causes |
Using the |
Maybe we could improve the performance of the whole process if instead of dumping the asset in the What do you think? |
@acasademont I do think it's worth trying, nice suggestion. |
@acasademont This would not work:
|
True, I currently have some .less files that import other .less files. A change in one of the imported l.ess files would not change the content of the main .less file, thus the hash would remain the same. Forget about it! |
Still not sure about the PR? |
@acasademont given the performance impact of the content strategy, I'm not sure at all it should be used by default. |
I think the "enabled" node in the configuration should be renamed "disabled" and the default value be %kernel.debug%. Cache busting would be enabled in production mode because that is what you usually want in a production environment and you often do not care about the performance impact since it is only used when deploying. And it would be disabled in development mode since the performance matters and this feature is useless in that environment. |
There is a bug when calling assetic:dump with CacheBustingWorker enabled and assets with vars. kriswallsmith/assetic#312 |
Besides the bug, I have been testing the performance of assetic with the cache busting enabled and here are my results. The test case consists of one .less file wich imports some other less files in turn, some javascripts and a .sass file compiled with compass. In total there are 240KB of less, 196KB of sass and 560KB of javascript No busting: 6.9s avg So there is a performance penaly when using the content strategy, a penalty that is dependant on the files size. But as you can see, the penalty is very acceptable, just 32% slower. @leek could you please tell us your results? I didn't get even close to 2x penalty, so 5x seems a lot to me. However, I am -1 on enabling this by default, it is an extra feature that maybe not everybody wants/needs and although the penalty is not terrible, ther is some. The PR as is now does not enable the busting feature by default, fine with that! |
Who cares about the speed, it happens only in production when you deploy, is not a runtime delay, isn't? |
The worker no longer has multiple strategies. Can someone update? |
👍 |
@stof, @kriswallsmith Is anything happening on this problem? If no - what are suggested ways for cache busting? |
Any news on whether this might be merged soon? 👍 |
@stof Are you still on this? (No offense, you are just the one who opened this PR) |
+1 |
@stof @kriswallsmith Any idea if/when this will be merged? |
+1 |
+1 |
+1 Without automatic cache busting, it's quite painful to manually clear cache in rapid deployment approach. |
👍 |
1 similar comment
👍 |
👍 , but there is no need for strategy anymore since kriswallsmith/assetic@8b43be9 Is there a "clean" way to do a similar thing the time this PR is merged ? |
Just to answer my last question, I found the answer : http://stackoverflow.com/questions/14399288/how-to-use-assetic-with-cachebustingworker-and-twig/19495577#19495577 |
In that case, should this PR be reworked so that it supports the new way to add the CacheBustingWorker? It would be nice to be able to set it from config.yml and maybe even enable it by default. |
Would prefer to not enable it by default (actually just because of BC), but a simple
would be nice 😄 |
I have forked and updated this PR in #240. Let's hope it makes it in this time! |
@stof @kriswallsmith Any news on this one please? |
fwiw I got this working with a simple service definition services:
assetic.worker.cache_busting:
class: Assetic\Factory\Worker\CacheBustingWorker
public: false
tags:
- { name: assetic.factory_worker } |
@merk Works like a charm Tim, thanks :) |
Closing in favor of the updated PR |
$this->assertSaneContainer($this->getDumpedContainer()); | ||
} | ||
|
||
public function getCacheBustingWorkerKeys() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO thats worth two different tests
- They test two different cases, not just different values for the same case, or similar cases.
- You'll probably never add more values, to cover other cases, because there only two boolean values.
@kingcrunch After the merge of the other PR and 6ac666e tweaking it, the shortest config is assetic:
workers:
cache_busting: ~ |
This PR was merged into the 2.5 branch. Discussion ---------- Added cache_busting to default asset config See: symfony/assetic-bundle#119 Commits ------- 733de39 Added cache_busting to default asset config
This adds the configuration for kriswallsmith/assetic#297
I'm wondering if the worker should be enabled by default or no.