倒FilesMatch? [英] inverted FilesMatch?

查看:238
本文介绍了倒FilesMatch?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置缓存控制标头文件。我想设置最大年龄= 86400 所有的.css 的.js 最大年龄= 3600 对于所有其他人。

I'm setting cache control headers for files. I want to set max-age=86400 for all .css and .js, and max-age=3600 for all others.

<FilesMatch "\.(css|js)$">
    Header append Cache-Control max-age=86400
</FilesMatch>

<FilesMatch "???">
    Header append Cache-Control max-age=3600
</FilesMatch>

我想不出有什么正则表达式我应该写颠倒 \。(CSS | JS)$ 匹配。或者,也许还有一些其他的方式来做到这一点?

I can't figure out what regex I should write to invert \.(css|js)$ match. Or maybe there is some other way to do this?

更新。基于这个问题回答我已经找到解决方案,它的工作原理:

UPDATE. Based on this question answer I've found solution that works:

<FilesMatch "(?<!\.css|\.js)$">
    Header append Cache-Control max-age=3600
</FilesMatch>

很遗憾不能找到一种方式离开点 \ 括号之外。但还是这个解决方案对我很好。

Unfortunatelly can't find a way to leave dot \. outside of brackets. But still this solution fine for me.

作为一个侧面说明,的所有其他文件的包括那些与文件名不是在所有的,如 http://example.com/

As a side note, all other files include ones with not filename at all, like http://example.com/.

推荐答案

根据这个问题答案我已经找到解决方案,它的工作原理:

Based on this question answer I've found solution that works:

<FilesMatch "(?<!\.css|\.js)$">
    Header append Cache-Control max-age=3600
</FilesMatch>

很遗憾不能找到一种方式离开点 \ 括号之外。但还是这个解决方案对我很好。

Unfortunatelly can't find a way to leave dot \. outside of brackets. But still this solution fine for me.

这篇关于倒FilesMatch?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆