You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-12Lines changed: 20 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,15 @@ Ever wanted to ensure that your most recently deployed asset files (eg: css, js,
4
4
5
5
Then look no further...!
6
6
7
-
This grunt plugin inserts a **cache avoiding** string into your asset filename, then looks for and updates any reference to it within your template file(s).
7
+
This [Grunt](https://gruntjs.com/) plugin inserts a **cache avoiding** string into your asset filename, then looks for and updates any reference to it within your template file(s).
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as how to install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
18
18
@@ -26,8 +26,8 @@ Once the plugin has been installed, it may be enabled inside your Gruntfile with
26
26
grunt.loadNpmTasks('grunt-cache-killer');
27
27
```
28
28
29
-
Alternatively, install the 'load-grunt-tasks' plug (`npm install --save-dev load-grunt-tasks`) and add the following line of code to your gruntfile.js `require('load-grunt-tasks')(grunt);` to automatically load your plugin(s).
30
-
29
+
Alternatively, install the [load-grunt-tasks](https://www.npmjs.com/package/load-grunt-tasks) plugin to have cacheKiller loadautomatically.
30
+
31
31
## The "cacheKiller" task
32
32
33
33
### Overview
@@ -51,12 +51,14 @@ grunt.initConfig({
51
51
52
52
### Options
53
53
54
-
-`prepend` (string) - A string value that is used to add characters to the front of the `[mask]`. The default value is an empty string.
54
+
-`prepend` (string) - A string value that is used to add characters to the front of the `[mask]` placeholder. The default value is an empty string.
55
55
56
-
-`append` (string) - A string value that is used to add characters to the back of the `[mask]`. The default value is an empty string.
56
+
-`append` (string) - A string value that is used to add characters to the back of the `[mask]` placeholder. The default value is an empty string.
57
57
58
58
-`mask` (string) - A string value that is used to specify the passed in mask. The default value is `{md5}`.
59
-
- If a **cacherKiller** mask function is used, then the string generated from that internal function is inserted. CacheKiller's mask functions include:
59
+
- If a **cacherKiller** mask function is used, then the string generated from that function will be inserted. If an invalid mask function is used, then an error message along with a full list of valid mask functions will be shown.
60
+
61
+
CacheKiller's mask functions include:
60
62
-`{timestamp}` eg: `1551278199614`
61
63
-`{datetimestamp}` eg: `20190228123639`
62
64
- All [OpenSSL](https://www.openssl.org/) algorithms available on your system. Some common algorithims include:
**Tip:** Use one of the below listed commands at the command prompt for a full list of available algorithms on your system.
72
+
```
73
+
// For newer versions of OpenSSL.
74
+
openssl list -digest-algorithms
68
75
69
-
For a full list of available algorithms, at the command prompt type `openssl list -digest-algorithms`.<br>
70
-
For older versions of OpenSSL, at the command prompt type `openssl list-message-digest-algorithms`.<br>
71
-
76
+
// For older versions of OpenSSL.
77
+
openssl list-message-digest-algorithms
78
+
```
79
+
72
80
- If a **string** is used, then that string is inserted. eg: `mask: 'my-string'`
73
81
74
82
- `length` (number) - A number value that is used to set the length of the mask. The default value is `-1`.
@@ -78,9 +86,9 @@ grunt.initConfig({
78
86
79
87
### Usage
80
88
81
-
Within the cacheKiller's `files:` node, place the `[mask]` within the asset filename where you would like the mask to be added.
89
+
Within the cacheKiller's `files:` node, place the `[mask]` placeholder within the asset filename where you would like the mask to be added.
82
90
83
-
> **Warning** - Do not place the `[mask]` at the very beginning or very end of the asset filename. Doing so prevents cacheKiller from properly determining where the start or end of the asset filename exists within the template file(s).
91
+
> **Note** - Do not place the `[mask]` placeholder at the very beginning or very end of the asset filename. (eg: `public/css/[mask].website.min.css`). Doing so would mangle the template file(s). CacheKiller prevents this from happening by showing an error message and terminating the script.
grunt.fail.warn(this.target+' : The options mask \''+$options.mask+'\' is not a valid mask. Valid masks include '+$validMaskFunctionTypes.join(', ')+'.');
232
+
}
233
+
185
234
// Build the tasks list.
186
235
var$tasks={};
187
236
@@ -202,9 +251,19 @@ module.exports = function (grunt) {
grunt.fail.warn(this.target+' : The position of the [mask] placeholder cannot be at the very beginning or very end of the asset filename. \''+$tasks[i].asset.name.full+'\' given.');
0 commit comments