Compass uses chunky_png to render the sprites. It adds a hash to the end of the file to force caches to download the new image sprites. Is there a way to turn this cache busting off?
相关问题
- Adding a timeout to a render function in ReactJS
-
Why does the box-shadow property not apply to a
- Add animation to jQuery function Interval
- jQuery hover to slide?
- Issue with star rating css
Unfortunately
asset_cache_buster :none
option does not disable adding the hash to the end of the filename.Like I wrote few time ago (in french), Compass has no way to disable the cache hash buster, but I propose a solution.
In your configuration file (eg
config.rb
) add the following lines:Now, uses
compass clean
to remove generated files and restarts a compilation withcompass compile
.You obtain, for example, a
images/icons-scb1e5456d5.png
file and aimages/icons.png
file. In the stylesheets, all references to the sprites now point to the version without hash.Be sure to keep the file has a hash provided to optimize compile times by Compass.
I haven't tested with sprites, but this works with
replace-text-with-dimensions
, for example:config.rb:
Found at The compass configuration file at caring.com
Set
asset_cache_buster :none
in your config.rb as documented in their configuration referenceBetter solution can be found in another similar question.
It's better because:
.css
auto generated file. It's generated with correct name from beginning.cp
(copy) of generated sprite with hash and it stays in file system / repo as duplicate which is quite bad. Additionally it's still seen as changed with local repo so you commit two identical files. Solution could domv
to change generated hash file name to clear one, but in this case sprite would be generated every time you use it in.scss
file so it's even worse.