app.yaml:带有static_dir的URL中的通配符? [英] app.yaml : wildcard in URL with static_dir?
问题描述
我尝试在app.yaml中匹配正则表达式作为目录名称不起作用:
- url:/ v1_ 。*
static_dir:static / v1
过期:364d
此官方规范表示支持regex语法。有没有办法做到这一点?
I。 我使用Google App Engine为 Go webapp。 我想最大限度地提高浏览器缓存的使用寿命,尽量减少请求次数,仍然服务于我的css / js / png的新版本,我相信启用文件名是实现此目的的最佳实践。另外,因为添加变量查询字符串( /v1_2014-01-29/img/logo.png
应与静态文件 /static/v1/img/logo.png $ c匹配
琐事
/v1/img/logo.png?2014-01-29
)可能会导致代理和缓存问题,所以我更愿意显示可变目录名称( /v1_2014-01-29/img/logo.png
),指向相同的底层服务器目录。 >解决方案
对我来说,无论URL超出url定义匹配的部分(从头开始匹配)都会附加到static_dir。
因此,如果文件路径是 static,那么以下处理程序应匹配
(用Python试过): /v1_2014-01-29/img/logo.png
/v1/img/logo.png
- url:/ v1_ (\ d + - ?)+
static_dir:static / v1
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 ?
I.e. /v1_2014-01-29/img/logo.png
should match the static file /static/v1/img/logo.png
.
Trivia
I use Google App Engine to serve a Go webapp.
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.
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.
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屋!