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
[](https://github.com/midnight-coding/grunt-cache-killer/releases)[](https://github.com/midnight-coding/grunt-cache-killer/blob/master/LICENSE-MIT)[](https://github.com/midnight-coding/grunt-cache-killer/milestones?state=open)[](https://github.com/midnight-coding/grunt-cache-killer/milestones?state=closed)
6
+
7
+
---
8
+
3
9
Ever wanted to ensure that your most recently deployed asset files (eg: css, js, img, etc) are being used instead of the old long-term cached versions?
4
10
5
11
Then look no further...!
@@ -9,6 +15,23 @@ This [Grunt](https://gruntjs.com/) plugin inserts a **cache avoiding** string in
-`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
84
58
85
-`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 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.
86
+
- If a **cacheKiller** mask function is used (ie: Anything surrounded by curly braces. eg: `{...}`), 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
87
61
88
CacheKiller's mask functions include:
62
89
-`{timestamp}` eg: `1551278199614`
63
90
-`{datetimestamp}` eg: `20190228123639`
64
-
- All [OpenSSL](https://www.openssl.org/) algorithms available on your system. Some common algorithims include:
91
+
- All [OpenSSL](https://www.openssl.org/) algorithms available on your system. Some common algorithms include but are not limited to:
**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
75
-
76
-
// For older versions of OpenSSL.
77
-
openssl list-message-digest-algorithms
78
-
```
98
+
> **Tip:** Use one of the below listed commands at the command prompt for a full list of available algorithms on your system.
99
+
> ```
100
+
> // For newer versions of OpenSSL.
101
+
> openssl list -digest-algorithms
102
+
>
103
+
> // For older versions of OpenSSL.
104
+
> openssl list-message-digest-algorithms
105
+
> ```
79
106
80
107
- If a **string** is used, then that string is inserted. eg: `mask: 'my-string'`
81
108
82
109
- `length` (number) - A number value that is used to set the length of the mask. The default value is `-1`.
83
110
- If the value of the number is negative (eg: `-1`) then the length of the given / generated string remains unchanged.
84
111
- If the value of the number if positive (eg: `8`) then only that value of right-hand characters in the string will remain.
85
-
- If the value of the number is zero (eg: `0`) then the mask string (excluding the prepend and append strings) is not used.
112
+
- If the value of the number is zero (eg: `0`) then the mask string (excluding the prepend and append strings) is not used. (ps: Considering the primary function of cacheKiller is to place masks within filenames, use of this value would be redundant exercise).
86
113
87
114
### Usage
88
115
89
-
Within the cacheKiller's `files:` node, place the `[mask]` placeholder within the asset filename where you would like the mask to be added.
116
+
If this is the first time you are running cacheKiller, it will insert the mask value into the asset filename and update any reference to it within your nominated template file(s).
90
117
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.
118
+
Running cacheKiller again will refresh the previously inserted mask value mask value of the asset filename with an updated value and again update any reference to it within your nominated template file(s).
119
+
120
+
Whether this is the 1st or 1,000th time your asset and template files have been updated, cacheKiller will insert the mask in the specified location each and every time.
121
+
122
+
Implementation is simple. Within the cacheKiller's `files:` node, place the `[mask]` placeholder within the asset filename where you would like the mask to be added.
123
+
124
+
```js
125
+
// Here...
126
+
'public/css/website[mask].min.css'
127
+
128
+
// Or here...
129
+
'public/css/website.min[mask].css'
130
+
131
+
// Or anywhere else you like within the asset filename, pursuant to the below limitations.
132
+
```
92
133
134
+
#### Limitations
135
+
136
+
- Do not place the `[mask]` placeholder within a directory. (eg: `public/[mask]/website.min.css`). CacheKiller is not designed to rename / update directory names, only filenames.
137
+
138
+
- 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 knows this, so to prevent it from happening cacheKiller will show you an error message and terminate the script.
139
+
140
+
- Do not move the `[mask]` placeholder back or forth within the asset filename if you have already run cacheKiller against that asset filename. Doing so **_will_** mangle the asset filename and any reference to it in the template file(s). If the `[mask]` is moved, there **_will_** be remnants of the previously added mask within the asset filename and template file(s). Whilst this may not necessarily break your applications functionality, it will break any compliance rules you may have around the naming of files.<br><br>
141
+
If you need to retrospectively move the `[mask]` placeholder back or forth within the asset filename, follow the below listed steps:
142
+
1. Rename the asset filename back to a generic filename. eg: `website.min.css`.
143
+
2. Update any and all references to the asset filename within the template file(s) using the same generic filename. eg: `website.min.css`.
144
+
3. Within the cacheKiller task, move the asset filenames `[mask]` placeholder to it's new position.
145
+
4. Run the cacheKiller task.
146
+
147
+
- Do not rename the asset filename if you have already run cacheKiller against that asset filename. Doing so will show you an error message and terminate the script.<br><br>
148
+
If you need to retrospectively rename the asset filename, follow the below listed steps.
149
+
1. Rename the asset filename to your new filename. eg: `new.website.min.css`.
150
+
2. Update any and all references to the asset filename within the template file(s) using your new filename. eg: `new.website.min.css`.
151
+
3. Within the cacheKiller task, insert the asset filenames `[mask]` placeholder within the new asset filename. eg: `public/css/new[mask].website.min.css`.
152
+
4. Run the cacheKiller task.
153
+
93
154
### Usage Examples
94
155
95
156
#### Default Options
@@ -99,12 +160,12 @@ In this example, the default options are used.
If you happen to come across any issues or bugs whilst using cacheKiller, please run your cacheKiller task with the cli `--debug` option enabled. The resulting report can then be copied and pasted inside your issue request. Adding this report to your issue request will reduce the time needed to identify and fix any bugs.
371
+
200
372
## Contributing
201
373
202
374
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).
0 commit comments