Add timestamp to avoid the cache. (.js/.css files)


Add timestamp & MD5 hash to avoid file cache. (.js/.css files)

NPM Home Page:

This plugin requires Grunt ~0.4.1

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-timestamp --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:


In your project's Gruntfile, add a section named timestamp to the data object passed into grunt.initConfig().

  timestamp: {
      default: {
        files: [{
          // Use dynamic extend name 
          expand: true,
          // Open source dir 
          cwd: 'test/fixtures',
          // Match files 
          src: ['*.css', '*.js'],
          // Output files 
          dest: 'test/tmp',
          // Set extend middle name 
          ext: '.timestamp'
        options: {
          // Timestamp display text 
          'timestampName': 'Timetamp',
          // Date format 
          'timestampFormat': 'yyyy/mm/dd HH:MM:ss',
          // Add timestamp at the end of the files' content(.css/.js). 
          'timestampType': 'md5',
          // Timestamp type like time(2014/04/02 22:17:07) | md5/sha1/ha256/sha512). 
          'fileEndStamp': true,
          // Add timestamp at images of CSS style. 
          'cssImgStamp': true,
          // Rename file name with timestamp inside. 
          'fileNameStamp': true
  • 0.0.8 move string to the front.
  • 0.0.7 Fix dest path & remove extra log
  • 0.0.6 Add more type like (sha1 | ha256 | sha512)
  • 0.0.5 MD5 string stamp supported
  • 0.0.4 Add support to .js file
  • 0.0.1 First Release
  • Add timestamp at images of CSS style.
  • Rename file name with timestamp inside.