2017 © Pedro Peláez
 

library grunt-cache-buster

A Laravel 4 package that works with Grunt for cache busting.

image

aozisik/grunt-cache-buster

A Laravel 4 package that works with Grunt for cache busting.

  • Wednesday, April 29, 2015
  • by aozisik
  • Repository
  • 1 Watchers
  • 2 Stars
  • 165 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 1 Versions
  • 6 % Grown

The README.md

Laravel Grunt Cache Buster

This is a simple cache buster for Laravel 4 framework and Grunt task manager. The package depends on grunt-cachebuster npm module (felthy/grunt-cachebuster). After you install the npm module and this package, all you have to is add a service provider and configure your Gruntfile.js. No modification in .htaccess or NGINX configuration modifications are necessary., (*1)

Configuring Grunt

First add the following module to your package.json and run npm :, (*2)

"grunt-cachebuster": "^0.1.5"

Add this to your grunt.initConfig, (*3)

cachebuster: {
    build: {
      options: {
          basedir: 'public/',
          format: 'php',
          banner:
              '/**\n' +
              ' * GENERATED FILE, DO NOT EDIT. This file is simply a collection of generated hashes for static assets in \n' +
              ' * the project. It is generated by grunt, see Gruntfile.js for details.\n' +
              ' */'
      },
      src: ['public/**/*'],
      dest: 'app/config/cachebuster.php'
    }
}

And then load the npm task and register it where necessary, (*4)

grunt.loadNpmTasks('grunt-cachebuster');
//..
//..
grunt.registerTask('buster', ['cachebuster']);

Make sure the cache buster task runs after all the other tasks. It will generate a file in your app/config directory by default. The package depends on this config file to function properly. After you set things up properly, run grunt and make sure it generates "cachebuster.php" file properly., (*5)

Configuring Laravel

Install this package by adding the following dependency to your L4 project:, (*6)

"aozisik/grunt-cache-buster": "dev-master"

After the installation, you need to add the following service provider in your app/config/app.php:, (*7)

'Aozisik\GruntCacheBuster\GruntCacheBusterServiceProvider'

Then wherever you want a cache-busted asset you can use the following instead of the default asset() helper, (*8)

CacheBusted::asset('js/resultsCtrl.js')

The code above, used instead of the default asset helper, will yield the following URL:, (*9)

http://demo.app/js/resultsCtrl.js?v=23d85993f132d67754489e47f66cf6ac

Enjoy!

If you have any questions to ask or bugs to report, feel free to contact me..., (*10)

The Versions

29/04 2015

dev-master

9999999-dev

A Laravel 4 package that works with Grunt for cache busting.

  Sources   Download

The Requires

 

by Ahmet Ozisik