edits
This commit is contained in:
parent
a719edef94
commit
ad5ecbd595
|
@ -1,5 +1,5 @@
|
||||||
+++
|
+++
|
||||||
date = '2024-11-13T14:24:21+01:00'
|
date = '2024-11-14T14:24:21+01:00'
|
||||||
draft = false
|
draft = false
|
||||||
title = 'Invalidating the browser cache'
|
title = 'Invalidating the browser cache'
|
||||||
tags = ['css','html','linux']
|
tags = ['css','html','linux']
|
||||||
|
@ -34,7 +34,7 @@ Of course there is.
|
||||||
Look at this:
|
Look at this:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet" href="css/defaults.css?2"/>
|
<link rel="stylesheet" href="css/defaults.css?v=2"/>
|
||||||
```
|
```
|
||||||
|
|
||||||
As I'm requesting the file via http, I can append a query. Awesome. Not awesome enough though. I'm too lazy to edit this line of code every time I push a commit, and, being human, I'll probably forget at a critical moment. This can only mean one thing: it's time to bash (🤣) out a quick build script.
|
As I'm requesting the file via http, I can append a query. Awesome. Not awesome enough though. I'm too lazy to edit this line of code every time I push a commit, and, being human, I'll probably forget at a critical moment. This can only mean one thing: it's time to bash (🤣) out a quick build script.
|
||||||
|
@ -43,7 +43,7 @@ As I'm requesting the file via http, I can append a query. Awesome. Not awesome
|
||||||
```bash
|
```bash
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
COMMIT="$(git rev-parse HEAD)"
|
COMMIT="$(git rev-parse HEAD)"
|
||||||
sed -i "s/css?=\w*/css?${COMMIT}/g" index.html
|
sed -i "s/css?v=\w*/css?${COMMIT}/g" index.html
|
||||||
```
|
```
|
||||||
|
|
||||||
Let's talk about what's happening here:
|
Let's talk about what's happening here:
|
||||||
|
@ -56,7 +56,7 @@ Now, whenever we push a new commit, any CSS imports in `index.html` will be chan
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="css/styles.css?=ab184410c10c1adfb8b85b03b316f72b"
|
href="css/styles.css?v=ab184410c10c1adfb8b85b03b316f72b"
|
||||||
/>
|
/>
|
||||||
```
|
```
|
||||||
Now I just need to add the build script to my Jenkinsfile...
|
Now I just need to add the build script to my Jenkinsfile...
|
||||||
|
|
Loading…
Reference in New Issue