app.yaml : 带有 static_dir 的 URL 中的通配符? [英] app.yaml : wildcard in URL with static_dir?
问题描述
我在 app.yaml 中将正则表达式匹配为目录名称的尝试不起作用:
My attempt at matching a regex as directory name in app.yaml doesn't work :
- url: /v1_.*
static_dir: static/v1
expiration: "364d"
虽然这个官方规范说支持正则表达式语法.有没有办法让这个工作?
Although this official spec says regex syntax is supported. Is there a way to make this work ?
即/v1_2014-01-29/img/logo.png
应该与静态文件 /static/v1/img/logo.png
匹配.
I.e. /v1_2014-01-29/img/logo.png
should match the static file /static/v1/img/logo.png
.
我使用 Google App Engine 来提供 Go webapp.
I use Google App Engine to serve a Go webapp.
我想最大限度地延长浏览器缓存的寿命,最大限度地减少请求数量,并且仍然提供我的 css/js/png 的新版本,我相信 revving filenames 是实现此目的的最佳实践.此外,由于添加变量查询字符串 (/v1/img/logo.png?2014-01-29
) 可能会导致代理和缓存问题,我更喜欢显示变量目录名称 (/v1_2014-01-29/img/logo.png
),指向同一个底层服务器目录.
I'd like to maximize browser cache longevity, minimize number of requests and still serve the fresh versions of my css/js/png, and I believe revving filenames is a best practice to achieve this. Also as adding a variable querystring (/v1/img/logo.png?2014-01-29
) might cause proxy and cache problems, I prefer to show a variable directory name (/v1_2014-01-29/img/logo.png
), pointing to the same underlying server dir.
推荐答案
在我看来,超出 url 定义匹配(从一开始就匹配)的 URL 的任何部分都将附加到 static_dir.
Seems to me that whatever part of the URL that is beyond the match of the url definition (which matches from the start) is appended to the static_dir.
因此,如果文件路径为 static/v1/img/logo.png
,则以下处理程序应匹配 /v1_2014-01-29/img/logo.png
(用 Python 试过):
So the following handler should match /v1_2014-01-29/img/logo.png
if the file path is static/v1/img/logo.png
(tried with Python):
- url: /v1_(d+-?)+
static_dir: static/v1
这篇关于app.yaml : 带有 static_dir 的 URL 中的通配符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!