I am playing with CommandBox rules and have a ques...
# box-products
l
I am playing with CommandBox rules and have a question about the regex directive
I am using this: "regex('**/*.png') -> set(attribute='%{o,Cache-Control}', value='3600')",
but when I add this and restart the cmdbox server it times out and won't start
Am I doing this right?
the rules section: "rules": [ Ā  Ā  "regex('**/*.js') -> set(attribute='%{o,Cache-Control}', value='3600')" ],
d
start commandbox server with trace and console props:
server start --trace --console
you should see why its not starting up there
l
I have got the service starting again.
I think there is an issue with the documentation.
šŸ¤” 1
d
whats the issue? and how did you get your server started?
l
Lucee was telling me that there was a: [ERROR] java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 */.png ^
So I started using some of the other examples in the docs. I eventually got to this line: "regex(pattern='/assets/(css|images|js)/') -> set(attribute='%{o,Cache-Control}', value='max-age=86400')", Which kill a couple of birds with one stone
But this line in the doc does not work: regex('**/index.*') -> set(attribute='%{o,Cache-Control}', value='no-cahce')
there is also a typo.
d
I added those examples and I remember the typo. I believe I submitted a new PR for that. I'll check
b
@laslo7 I don't understand your regex-- it's not valid
I think you're trying to use file globbing patterns, which are not the same as regex!
*
in regex means any number of matches of the preceding character
SO starting a regex string with * make zero sense
You have to FOLLOW a character with the star -- like
.*
@Daniel Mejia If there's an open PR for any typos, please send me the URL. If not, please correct any wrong examples if you added them in the docs
šŸ‘šŸ¾ 1
All server rules examples I added personally, I tested first on a local server to ensure they were correct. I would hope you would do the same before submitting additional pulls šŸ™‚
šŸ‘šŸ¾ 1
d
will do
l
@bdw429s which regex are your referring too? Is it this one: regex('**/index.*') -> set(attribute='%{o,Cache-Control}', value='no-cahce')
I got that from the docs and worked my way to a working version.
My current line seems to work great. "regex(pattern='/assets/(css|images|js)/') -> set(attribute='%{o,Cache-Control}', value='max-age=86400')"
d
the PR for the typos and the correct regex pattern has been submitted. @laslo7 yes he meant that '**' this is not a regex thing. That is meant for file globbing patterns.