Welcome to WebmasterWorld Guest from 54.166.152.121

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)

5+ Year Member



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)

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



<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)

5+ Year Member



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)

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



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)

5+ Year Member



OK like this?

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

5+ Year Member




OK like this?

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

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



\. matches a literal period.

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

5+ Year Member



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)

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



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month