Last active
March 16, 2022 15:24
-
-
Save ensean/15e74506cf284728c8355e831fb38afb to your computer and use it in GitHub Desktop.
cff_response_content_type_by_ua
This file contains hidden or 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
function handler(event) { | |
var response = event.response; | |
var request = event.request; | |
var ua = request.headers['user-agent']['value'].toLowerCase(); | |
var headers = response.headers; | |
if (ua.indexOf('chrome') > -1) { | |
// Set the cache-control header | |
headers['content-type'] = {value: "application/vnd.android.package-archive"}; | |
} | |
else if (ua.indexOf('firefox') > -1){ | |
headers['content-type'] = {value: "image/png"}; | |
} | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
绑定 viewer response事件,配置方式参考 https://docs.aws.amazon.com/zh_cn/AmazonCloudFront/latest/DeveloperGuide/edge-functions.html