This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(purgeCache(event.request)) | |
}) | |
async function purgeCache(request) { | |
const url = new URL(request.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(byPassOrBlock(event.request)) | |
}) | |
async function byPassOrBlock(request) { | |
let url = new URL(request.url) | |
let blockedCountries = ['XX'] | |
let whitelistedPaths = ['/about*'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(fetchAndApply(event.request)) | |
}) | |
/** | |
* If the browser is requesting an image and | |
* the referer does not match your host | |
* we redirect the request to your page | |
*/ | |
async function fetchAndApply(request) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(ignoreQueryString(event.request)) | |
}) | |
async function ignoreQueryString(request) { | |
let url = new URL(request.url) | |
url.search = '' | |
let modifiedRequest = new Request(url, request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener('fetch', event => { | |
event.respondWith(fetchAndApply(event.request)) | |
}) | |
function isMobile(userAgent) { | |
return userAgent.match(/iPhone|Android|webOS/i) ? 'Yes' : 'No'; | |
} | |
async function fetchAndApply(request) { | |
let isMobileResult = isMobile(request.headers.get('user-agent')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ionice -c2 nice -n19 mysqldump --opt --single-transaction --quick --hex-blob --events --force --user=$MYSQLUSER -p $db | ionice -c2 nice -n19 gzip > sql_dump.sql.gz |