Skip to content

Commit

Permalink
Use gzip instead of brotli for HTML requests to workaround snarfed/br…
Browse files Browse the repository at this point in the history
…idgy#878 to get bridgy working again.
  • Loading branch information
zachleat committed Jun 29, 2019
1 parent fe963d2 commit 583b0a2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
6 changes: 6 additions & 0 deletions .htaccess
Expand Up @@ -3,7 +3,12 @@ RewriteEngine On
RewriteBase /
RewriteRule résumé/$ /resume/ [L]

RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteCond %{REQUEST_FILENAME}.zgz -f
RewriteRule ^(.*)$ $1.zgz [L]

RewriteCond %{HTTP:Accept-Encoding} br
#RewriteCond %{HTTP:Accept-Encoding} !br;q=0
RewriteCond %{REQUEST_FILENAME}.zbr -f
RewriteRule ^(.*)$ $1.zbr [L]

Expand All @@ -27,6 +32,7 @@ RedirectMatch 301 /web/\d{4}/(.*)$ /web/$1

# mod_deflate isn't included on the production host, so we have a workaround above
AddEncoding br .zbr
AddEncoding gzip .zgz

#<IfModule mod_deflate.c>
#AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
Expand Down
36 changes: 27 additions & 9 deletions Gruntfile.js
Expand Up @@ -52,7 +52,7 @@ module.exports = function(grunt) {
'node_modules/infinity-burger/infinity-burger.js',
'<%= config.jsSrc %>fontloademu.js',
'<%= config.jsSrc %>google-analytics.js',
'<%= config.jsSrc %>twitter-api.js',
// '<%= config.jsSrc %>twitter-api.js',
'<%= config.jsSrc %>lazyimg.js',
// '<%= config.jsSrc %>fouterswap.js',
],
Expand Down Expand Up @@ -133,22 +133,40 @@ module.exports = function(grunt) {
}
},
compress: {
main: {
mainGzip: {
options: {
mode: 'brotli',
brotli: {
mode: 1
}
mode: 'gzip'
},
// only do HTML files to comply with webmention brid.gy bug https://github.com/snarfed/bridgy/issues/878
// when that bug is fixed, this can go away (and .htaccess stuff for gzip)
files: [
{
expand: true,
cwd: '_site/',
src: ['**/*.html'],
dest: '_site/',
extDot: 'last',
ext: '.html.zbr'
},
ext: '.html.zgz'
}
]
},
mainBrotli: {
options: {
mode: 'brotli',
brotli: {
mode: 1
}
},
files: [
// reenable when bridgy bug above in compress:mainGzip task is fixed.
// {
// expand: true,
// cwd: '_site/',
// src: ['**/*.html'],
// dest: '_site/',
// extDot: 'last',
// ext: '.html.zbr'
// },
{
expand: true,
cwd: '_site/',
Expand Down Expand Up @@ -210,7 +228,7 @@ module.exports = function(grunt) {
},
clean: {
drafts: [ '_site/web/drafts/**' ],
compressed: [ '_site/**/*.zbr' ]
compressed: [ '_site/**/*.zbr', '_site/**/*.zgz' ]
},
watch: {
assets: {
Expand Down
2 changes: 1 addition & 1 deletion _data/webmentions.js
Expand Up @@ -31,7 +31,7 @@ async function fetchWebmentions(since) {
// TODO move to use since_id instead of since date
let url = `${API_ORIGIN}?domain=${domain}&token=${TOKEN}`;
if (since) {
url += `&per-page=100&&since=${since}`;
url += `&per-page=999&&since=${since}`;
} else {
url += `&per-page=999`;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "zachleat.com",
"version": "2.0.8",
"version": "2.0.9",
"description": "The website of @zachleat",
"dependencies": {
"fg-loadcss": "^1.3.1",
Expand Down

0 comments on commit 583b0a2

Please sign in to comment.