icflorescu / aspax

The simple Node.js asset packager.
aspax.github.io
MIT License
17 stars 0 forks source link

Fingerprints #1

Closed mahnunchik closed 10 years ago

mahnunchik commented 10 years ago

@icflorescu : About using hash fingerprints to avoid unnecessary cache busting - yes, that's a very good idea, I thought about it but couldn't come up with a clean and elegant solution. It would be kind of complicated to implement, since ASPAX is also replacing asset URLs in CSS files where needed. Please have a look at the code and if you can come up with a solution, I'm open.

I solved this problem this way:

  1. Try to find already copied files by simple path css.coffee#L17 (manager is like config in aspax)
  2. Try to find already copied files by full path css.coffee#L20
  3. Try to make new asset without configuration css.coffee#L25

This means that CSS is completed after all dependencies have been copied and fingerprinted.

The third step was a bad idea because it promotes duplication of dependencies (for example: with fingerprint and without).

ASPAX I think that aspax should not rely on order of mention in config. I think aspax should process CSS files by following steps:

  1. Try to find already copied and fingerprinted dependency in global config. If it is located before CSS in the configuration file.
  2. Try to find configuration of dependency in global config and make asset. If it is located after CSS in the configuration file.

Also it will be useful not only for CSS but for sourcemap assets too.

icflorescu commented 10 years ago

I'm still a bit reluctant to implementing this one... Don't know why, but I have a feeling the solution would become a bit too complicated without offering outstanding benefits... I know using MD5 would avoid cache busting for unmodified files, but since this only happens when doing a new deployment, it's not such a huge problem, wouldn't you agree?

mahnunchik commented 10 years ago

I will try to implement disordered creation of asset. If possible, we could add both md5 and timestamp fingerprints.