-
-
Notifications
You must be signed in to change notification settings - Fork 842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow higher customization for compiling assets #2318
Conversation
Would the alternative be keeping file names consistent across re-builds, and relying on the CDN to dictate which are cached when? And if so, wouldn't a better implementation of making this extensible be separating out the code that adds in that unique ID (I believe it's just a hash, but I don't remember off the top of my head) out? |
Yes there are four potential files involved. App CSS and js All of these are generated using a hash inside the filename, eg app-hash.js. The common consensus is to use the hash inside a query param, app.js?v=hash for instance. |
Is there a reason why we wouldn't just want to adopt that as the default behavior? With respect to the PR, I like the |
I didn't want to change the behavior so much, I could modify the PR to adopt the new scheme, but I will do that in the coming days then. |
Looking at online material again, there doesn't seem to be a specific consensus. I would keep the current logic but allow easier overriding, which this PR tries to solve. |
Really sorry for nitpicking on this one. One other question then: the current naming scheme (with the hash in filename) is determined by this>name, right? I'll need to take a look at the broader context again, but couldn't we extract the logic where this->name is created? |
Yeah the Assets class is instantiated with a base name assigned to property name. This name is then used to generate all file names by prefixing these with the name:
The final filename, including the version hash, is later generated in each compiler using the abstract compiler getFilenameForRevision method. This is great and I can override this method by creating a new subclass for each compiler and overriding the method with a trait. But overriding the Assets class to use these new compilers isn't possible when these methods are private, as they are now. Hey, this is not nitpicking. You need to ask these questions to get to the best result and I need to be patient in clarifying the exact need for these changes anyhow. |
Alright I think I get where you're coming from. Wouldn't the |
Okay, makes sense. Will revert those. |
One of the issues with the compiler logic is that it's hard to override it in case you need a different file naming convention. The current filenaming convention causes the forum to have no styling whenever an extension is enabled/disabled (cache is cleared) and you are using a CDN and/or horizontally scaled hosting environments. In case of cache invalidation nodes separately recompile the files, which isn't sensible in itself, but with a CDN involved becomes disastrous.