diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2021-03-26 21:03:34 -0400 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2021-03-26 21:03:34 -0400 |
| commit | 342a31c06cfa40be5ac50ac028578f25ce7bf0fd (patch) | |
| tree | cdbcd28cb24b07879bd81a7706e2b607d2f5fe43 | |
| parent | f5f23e2a95325f9748edcc5da4a3f21c9a18af92 (diff) | |
automate CSS/JS cache busting
| -rw-r--r-- | .gitignore | 1 | ||||
| -rwxr-xr-x | deploy_static | 4 | ||||
| -rw-r--r-- | nginx/nginx.conf | 2 | ||||
| -rwxr-xr-x | process_static | 12 | ||||
| -rw-r--r-- | static/404.html | 2 | ||||
| -rw-r--r-- | static/articles/grapheneos-servers.html | 2 | ||||
| -rw-r--r-- | static/articles/index.html | 2 | ||||
| -rw-r--r-- | static/articles/server-traffic-shaping.html | 2 | ||||
| -rw-r--r-- | static/articles/sitewide-advertising-industry-opt-out.html | 2 | ||||
| -rw-r--r-- | static/build.html | 4 | ||||
| -rw-r--r-- | static/contact.html | 2 | ||||
| -rw-r--r-- | static/donate.html | 2 | ||||
| -rw-r--r-- | static/faq.html | 4 | ||||
| -rw-r--r-- | static/features.html | 2 | ||||
| -rw-r--r-- | static/history.html | 2 | ||||
| -rw-r--r-- | static/index.html | 4 | ||||
| -rw-r--r-- | static/install/cli.html | 4 | ||||
| -rw-r--r-- | static/install/index.html | 4 | ||||
| -rw-r--r-- | static/install/web.html | 6 | ||||
| -rw-r--r-- | static/pdfviewer-privacy-policy.html | 2 | ||||
| -rw-r--r-- | static/releases.html | 6 | ||||
| -rw-r--r-- | static/source.html | 2 | ||||
| -rw-r--r-- | static/usage.html | 4 |
23 files changed, 47 insertions, 30 deletions
@@ -1,2 +1,3 @@ +nginx.conf.tmp node_modules static_tmp diff --git a/deploy_static b/deploy_static index 8daeb249..3de1ed42 100755 --- a/deploy_static +++ b/deploy_static @@ -25,5 +25,9 @@ ssh $remote sync -f $target ssh $remote ln -snf $target /var/www/html ssh $remote sync . +rsync -rpcv --chmod=D755,F644 --delete nginx.conf.tmp $remote:/etc/nginx/nginx.conf +ssh $remote sync -f /etc/nginx/nginx.conf +ssh $remote systemctl reload nginx + echo echo active is now $target diff --git a/nginx/nginx.conf b/nginx/nginx.conf index cae0ed50..f1ae783c 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -67,7 +67,7 @@ http { map $http_cookie $preload_resources { "~*__Host-preload=1" ""; - default "</grapheneos.css?29>; rel=preload; as=style, </fonts/roboto_latin.woff2?20>; rel=preload; as=font; crossorigin, </fonts/roboto_bold_latin.woff2?20>; rel=preload; as=font; crossorigin, </mask-icon.svg>; rel=preload; as=image"; + default "</grapheneos.css>; rel=preload; as=style, </fonts/roboto_latin.woff2?20>; rel=preload; as=font; crossorigin, </fonts/roboto_bold_latin.woff2?20>; rel=preload; as=font; crossorigin, </mask-icon.svg>; rel=preload; as=image"; } server { diff --git a/process_static b/process_static index e0b89c45..d11e030a 100755 --- a/process_static +++ b/process_static @@ -15,6 +15,18 @@ done find static_tmp -name '*.css' -exec csso {} -o {} \; find static_tmp -name '*.js' -exec terser --module -cmo {} {} \; + +replace="" +for file in static_tmp/**/*.css static_tmp/js/*.js; do + hash=$(sha256sum "$file" | head -c 8) + dest="$(dirname $file)/$hash.$(basename $file)" + mv "$file" "$dest" + replace+=";s/\\/$(basename $file)/\\/$(basename $dest)/g" +done + +cp nginx/nginx.conf nginx.conf.tmp +sed -i "$replace" static_tmp/**/*.html nginx.conf.tmp + find static_tmp -name '*.html' -exec html-minifier --collapse-whitespace \ --process-scripts "application/ld+json" --collapse-boolean-attributes \ --remove-attribute-quotes --remove-comments --remove-empty-attributes \ diff --git a/static/404.html b/static/404.html index b755ed62..c4a4b624 100644 --- a/static/404.html +++ b/static/404.html @@ -21,7 +21,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/articles/grapheneos-servers.html b/static/articles/grapheneos-servers.html index d8e61d9d..08556a42 100644 --- a/static/articles/grapheneos-servers.html +++ b/static/articles/grapheneos-servers.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/articles/index.html b/static/articles/index.html index f76f377d..aae1eb80 100644 --- a/static/articles/index.html +++ b/static/articles/index.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/articles/server-traffic-shaping.html b/static/articles/server-traffic-shaping.html index 8ff603b0..0492c807 100644 --- a/static/articles/server-traffic-shaping.html +++ b/static/articles/server-traffic-shaping.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/articles/sitewide-advertising-industry-opt-out.html b/static/articles/sitewide-advertising-industry-opt-out.html index b8a57026..0161d518 100644 --- a/static/articles/sitewide-advertising-industry-opt-out.html +++ b/static/articles/sitewide-advertising-industry-opt-out.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/build.html b/static/build.html index 336c8024..f4260f72 100644 --- a/static/build.html +++ b/static/build.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/contact.html b/static/contact.html index d9a0b46d..92319e51 100644 --- a/static/contact.html +++ b/static/contact.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/donate.html b/static/donate.html index b1f5a94b..9d440860 100644 --- a/static/donate.html +++ b/static/donate.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/faq.html b/static/faq.html index bdd21492..d8eece2a 100644 --- a/static/faq.html +++ b/static/faq.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/features.html b/static/features.html index f2a8adfc..958d6f07 100644 --- a/static/features.html +++ b/static/features.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/history.html b/static/history.html index cd96c0c7..6658c90b 100644 --- a/static/history.html +++ b/static/history.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/index.html b/static/index.html index 836a7b2d..2e64e086 100644 --- a/static/index.html +++ b/static/index.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/install/cli.html b/static/install/cli.html index 930f273b..193ec94b 100644 --- a/static/install/cli.html +++ b/static/install/cli.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/install/index.html b/static/install/index.html index 97d1b624..a7387bdd 100644 --- a/static/install/index.html +++ b/static/install/index.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/install/web.html b/static/install/web.html index 2128482f..aa8bcaa5 100644 --- a/static/install/web.html +++ b/static/install/web.html @@ -23,12 +23,12 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> <script type="module" src="/js/fastboot/dist/fastboot.min.mjs?1.0.8"></script> - <script type="module" src="/js/web-install.js?13"></script> + <script type="module" src="/js/web-install.js"></script> </head> <body> <header> diff --git a/static/pdfviewer-privacy-policy.html b/static/pdfviewer-privacy-policy.html index e7b574fa..c4b809d4 100644 --- a/static/pdfviewer-privacy-policy.html +++ b/static/pdfviewer-privacy-policy.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/releases.html b/static/releases.html index aaf7b27c..195a5c9f 100644 --- a/static/releases.html +++ b/static/releases.html @@ -24,11 +24,11 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/releases.js?14"></script> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/releases.js"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> diff --git a/static/source.html b/static/source.html index 14b612a4..0f70af59 100644 --- a/static/source.html +++ b/static/source.html @@ -23,7 +23,7 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> </head> diff --git a/static/usage.html b/static/usage.html index 8e0c5803..cc06407c 100644 --- a/static/usage.html +++ b/static/usage.html @@ -23,10 +23,10 @@ <link rel="icon" sizes="any" type="image/svg+xml" href="/mask-icon.svg"/> <link rel="mask-icon" href="/mask-icon.svg" color="#1a1a1a"/> <link rel="apple-touch-icon" href="/apple-touch-icon.png"/> - <link rel="stylesheet" href="/grapheneos.css?29"/> + <link rel="stylesheet" href="/grapheneos.css"/> <link rel="manifest" href="/manifest.webmanifest"/> <link rel="license" href="/LICENSE.txt"/> - <script type="module" src="/js/redirect.js?12"></script> + <script type="module" src="/js/redirect.js"></script> </head> <body> <header> |
