阿里云 Edgescript 示例

发布时间: 更新时间: 总字数:212 阅读时间:1m 作者: IP上海 分享 网址

阿里云CDN的边缘脚本(EdgeScript)技术,可以快速、灵活地实现CDN定制配置。如修改文件返回提能容等,是 CDN 的重要扩展内容。

修改response content-type

  • updatewasmcontenttype
if match_re($uri, '.wasm$') {
    del_rsp_header('Content-Type')
    add_rsp_header('Content-Type', 'application/wasm')
}

修改 .wasm 文件的 Content-Typeapplication/wasm

  • updatewoffcontenttype
if match_re($uri, '.woff$') {
    del_rsp_header('Content-Type')
    add_rsp_header('Content-Type', 'application/font-woff')
}

if match_re($uri, '^/$') {
    rewrite('/index.html', 'break')
}

修改 .woff 文件的 Content-Typeapplication/font-woff

发布 Vue 项目

发布 vue 项目时,访问时根路径,会出现 https://{domain}/index.html#/,看起来不是很舒服,我们可以通过下面的 EdgeScript 脚本修改,使返回值显示为 https://{domain}/#/

  • rewrite4vue
if match_re($uri, '^/$') {
    rewrite('/index.html', 'break')
}
Home Archives Categories Tags Statistics
本文总阅读量 次 本站总访问量 次 本站总访客数