Welcome to WebmasterWorld Guest from 54.166.179.165

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

<FilesMatch ".(js|css)$"> vs <filesMatch "\.(js|css)$">

     
1:44 pm on Nov 11, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


Specifically "\."

Should I include the slash or no? Whats it do?

this is part of a deflate htacces rule

<FilesMatch ".(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>

or there is this version

<filesMatch "(?i)^.*\.(ico|flv|jpg|jpeg|png|gif|js|css)$">

So..

"(?i)^.*\." vs "\." vs "."
2:26 pm on Nov 11, 2012 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10551
votes: 10


<FilesMatch ".(js|css)$"> vs <filesMatch "\.(js|css)$">

neither.

as far as i know the apache directives are case sensitive.
also the directive matches a "Perl Compatible Regular Expression", so you need the backslash to escape the dot.

<FilesMatch> Directive:
http://httpd.apache.org/docs/2.2/mod/core.html#filesmatch

(?i)

i would not make the file extensions case insensitive unless you are actually serving uppercase or mixed case file names.
2:30 pm on Nov 11, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


OK thanks. So what should this look like exactly?

<FilesMatch ".(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
2:39 pm on Nov 11, 2012 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10551
votes: 10


the directive matches a "Perl Compatible Regular Expression", so you need the backslash to escape the dot
2:53 pm on Nov 11, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


OK like this?

# Compress Files
<FilesMatch "\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
12:19 am on Nov 12, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0



OK like this?

# Compress Files
<FilesMatch "\.(js|css|html|htm|php|xml)$">
SetOutputFilter DEFLATE
</FilesMatch>
12:57 am on Nov 12, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:July 3, 2002
posts:18903
votes: 0


\. matches a literal period.

. matches ANY character.
1:37 am on Nov 12, 2012 (gmt 0)

Junior Member

5+ Year Member

joined:Dec 23, 2007
posts:143
votes: 0


Ok thanks! So prob better to match a period. I have a question you may know the answer to. I'm desperately trying to enable coaching for my website. I put this in my htaccess...

ExpiresActive On
ExpiresDefault "access plus 10 years"
ExpiresByType text/html "access plus 1 day"

But it's not caching. Reading for hours I see mod_expires needs to be on the server in order for my code to work. I have Hostgator shared server. I have talked to multiple tecks at Hostgator and they all are unable to give me an answer if they have mod_expires or mod_headers on the server. I am at a loss. Have any of you experienced any of this and possibly a fix?
3:12 am on Nov 12, 2012 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13059
votes: 301


Hm, thought this thread sounded familiar. Some hosts won't give out details about what mods are available or what version of Apache they're using. Mine won't-- but to make up for it they show you a nifty trick for revealing exactly which mods you have available. (The one that involves #printenv and an htaccess file. You've probably seen it.)

Are you testing it on new pages that you haven't previously visited? Emptying your browser cache or preferably testing in an entirely different browser? A default of "expires never" -- which is basically what "access plus 10 years" means -- will probably be overridden by some lower number set by your browser.

If the Expires header is intended to apply to everything, you don't need the <Files> or <FilesMatch> envelope at all. But that's the least of your problems.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members