Uploaded image for project: 'SmartSprites'
  1. SmartSprites

Sprite image MD5 hash or date should be part of file name rather than a request parameter


    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.2.8
    • Labels:



      As pointed out by Nicolas, when MD5 hash or date is appended as a request parameter (after ? character), proxies may not cache such images. For this reason, a better and recommended approach is to make the MD5 hash or date part of the file name.


      The implementation will introduce a simple variable substitution mechanism to be used in the sprite-image values. These will allow to weave a number of dynamic variables, such as MD5 hash, into the names of sprite images and the paths that reference sprite images in the generated background-image CSS properties.

      The format of the variables will follow Ant's property syntax, i.e. ${variable}. Initially, 3 variables will be resolved:

      • sprite – name of the sprite as declared in the sprite property
      • md5 – MD5 hash of the sprite image
      • date – a string representing current date and time in the YYYYMMDDHHmmssms format

      Additionally, to support a use case where cache busting values are not embedded in sprite names but follow after the ? character, the sprite-image property will allow inserting a query string at the end of the sprite image path. Sprite image file name will be determined by removing everything from the first occurrence of a ? character to the end of the sprite-image property value. The provided query string, with variables resolved, will be copied to the generated background-image CSS properties.

      SmartSprites should issue a warning when:

      • an unsupported variable is referenced
      • variable syntax seems malformed (unbalanced } or { characters)


      When this feature is implemented, the sprite-image-uid will become deprecated. Until support for sprite-image-uid is removed, it will work as currently specified, ie. append MD5 hash or date at the end of background-image, preceded by a ? character. Additionally, a warning will be issued that sprite-image-uid is deprecated and variables in sprite-image should be used instead.

      The sprite-image-uid will continue to be supported in the 0.2.x and 0.3.x versions, it will be removed in the 0.4.0 of SmartSprites.


      Although more complicated to implement, this design should support both the current and the new image hash use case. Additionally, it will prevent the explosion of new sprite-* properties, allow more flexibility when formatting sprite file names and allow adding further variables in the future. An interesting feature for the future might also be making the sprite-image directive optional and providing a configurable default value for it, e.g. ../img/{sprite}-{hash}.png.


          Issue Links



              • Assignee:
                stachoo Stanisław Osiński
                stachoo Stanisław Osiński
              • Votes:
                3 Vote for this issue
                1 Start watching this issue


                • Created:

                  Time Tracking

                  Original Estimate - 6h
                  Remaining Estimate - 0h
                  Time Spent - 5h 13m Time Not Required
                  5h 13m