hottrout

msg:4480588 | 2:41 pm on Jul 31, 2012 (gmt 0) |
Is it possible that the files are being cached but I am confusing caching with the cache validator? Can someone explain the difference and what I need to do to make this better code?
|
hottrout

msg:4493834 | 3:31 pm on Sep 11, 2012 (gmt 0) |
bump, I need some help with this
|
lucy24

msg:4493984 | 9:36 pm on Sep 11, 2012 (gmt 0) |
Don't know about anyone else, but just reading the post gives me a headache. Right now you seem to have -- all-purpose default -- some cache headers that give a longer time than the default -- some other cache headers that give a shorter time than the default # Preserve bandwidth for PHP enabled servers <ifmodule mod_php4.c> php_value zlib.output_compression 16386 </ifmodule> |
| ... and there's another peril of the <ifmodule> envelope. What if your host has surreptitiously gone to php5 when you weren't looking? Some hosts are skittish about disclosing the exact apache number, but you should know what php version you're working with and write the code accordingly. It's only for your own site, right? So you don't need any hypothetical <ifmodule> options. Incidentally: unless you've got a really ancient Apache installation, you can write all those times in English, like "access plus 2 hours" or "modification plus 3 days". Makes it easier to read later on. If your subdomains are physically located inside/below your primary domain, then anything in the top-level htaccess should apply everywhere. But the topic header implied that your special caching rules are only meant to apply in the subdomains. If so, you might be better off putting them in separate htaccess files. My own only venture into cache restrictions is limited to a single directory containing a handful of gif files, so I don't have any personal experience to buttress and/or modify what Apache says. I just know that it worked a treat once I'd got the wording exactly right.
|
hottrout

msg:4494154 | 8:51 am on Sep 12, 2012 (gmt 0) |
Lucy, thanks for the response, it is appreciated. I was lazy and should have updated the original post. In the time between my first post and my bump last night I had actually changed this code as follows :- # BEGIN Compress text files <ifModule mod_deflate.c> <filesMatch "\.(css|js|x?html?|php)$"> SetOutputFilter DEFLATE </filesMatch> </ifModule> # BEGIN Expire headers ExpiresActive On ExpiresDefault "now" # Configure mime expires ExpiresByType image/x-icon "access plus 30 days" ExpiresByType image/jpeg "access plus 14 days" ExpiresByType image/png "access plus 14 days" ExpiresByType image/gif "access plus 14 days" ExpiresByType application/x-shockwave-flash "access plus 7 days" ExpiresByType text/css "access plus 7 days" ExpiresByType text/javascript "access plus 7 days" ExpiresByType application/javascript "access plus 7 days" ExpiresByType application/x-javascript "access plus 7 days" ExpiresByType text/html "access plus 7 days" ExpiresByType application/xhtml+xml "access plus 8 hours" # Default - Set Cache-Control header to expire everything 3 days from last access ExpiresDefault A259200 Header set Cache-Control: "must-revalidate" # Cache images for up to two weeks -- no forced revalidation (longer than 2 weeks is pointless) <FilesMatch "\.(gif|jpe?g|png|js|bmp|ico|pdf|mov|wmv)$"> ExpiresDefault A1209600 Header set Pragma "public" Header append Cache-Control "public, must-revalidate, proxy-revalidate" </FilesMatch> # Infrequently updated -- expire after 3 days <FilesMatch "\.(html?|css|txt)$"> ExpiresDefault A259200 Header set Pragma "public" Header append Cache-Control "public, must-revalidate, proxy-revalidate" </FilesMatch> # Frequently-updated files, expire after 2 hour <FilesMatch "\.(php)$"> ExpiresDefault A7200 Header set Cache-Control: "no-cache, must-revalidate" </FilesMatch> Header unset ETag Header unset Last-Modified # Preserve bandwidth for PHP enabled servers php_value zlib.output_compression 16386 Now with this code I have noticed improvements, however it is still the case that google analytics does not see any subdomains as being cached. I have www.example.com and I also have two subdomains, files.example.com and images.example.com. These subdomains are just a record pointed to a subfolder of the main website. Can you advise as to why these subdomains do not seem to be cached?
|
phranque

msg:4494333 | 2:26 pm on Sep 12, 2012 (gmt 0) |
you have both ExpiresDefault "now" and ExpiresDefault A259200 in directory context so i'm not sure which would override if it comes to that. next i believe your regular expressions in the FilesMatch directives require a tilde (~) "operator". otherwise it may be ignoring these contexts. finally you should check that your subdomains are configured to properly supply mime types for these responses. otherwise the ExpiresByType directive won't help you.
|
hottrout

msg:4494343 | 3:28 pm on Sep 12, 2012 (gmt 0) |
Thanks for the reply. I have now removed the additional and unneeded ExpiresDefault. The FilesMatch is working without the tilde so it must be ok but I still dont get cache validation with the sub domains. Can you explain a little more how I can check that the subdomains are supplying mime types? One other point, if I use mime types to serup expires times, do I also need filesmatch as well?
|
phranque

msg:4494375 | 4:18 pm on Sep 12, 2012 (gmt 0) |
you can check the mime types on your subdomains by requesting those filetypes and checking the HTTP Response headers for a Content-Type header. the ExpiresDefault only matters if the ExpiresByType doesn't catch it. for example if you're server isn't recognizing mime-types...
|
hottrout

msg:4494378 | 4:25 pm on Sep 12, 2012 (gmt 0) |
When I used web sniffer to check the page I noticed that Cache-Control:no-cache, must-revalidate Expires:Wed, 19 Sep 2012 16:23:09 GMT This was the result of the main domain. Is this correct?
|
hottrout

msg:4494391 | 5:05 pm on Sep 12, 2012 (gmt 0) |
This is the current settings which are at the top of my htaccess. I also meant to say that the tilde is not required with FilesMatch. # BEGIN Expire headers ExpiresActive On ExpiresDefault "now" # Configure mime expires ExpiresByType image/x-icon "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/gif "access plus 1 month" ExpiresByType application/x-shockwave-flash "access plus 1 month" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" ExpiresByType application/javascript "access plus 1 month" ExpiresByType application/x-javascript "access plus 1 month" ExpiresByType text/html "access plus 8 hours" ExpiresByType application/xhtml+xml "access plus 8 hours" <FilesMatch "\.(css|ico|gif|jpe?g|png|js|pdf|mov|wmv)$"> ExpiresDefault "access plus 1 month" Header set Pragma "public" Header append Cache-Control "public, must-revalidate, proxy-revalidate" </FilesMatch> <FilesMatch "\.(html?|txt)$"> ExpiresDefault "access plus 3 days" Header set Pragma "public" Header append Cache-Control "public, must-revalidate, proxy-revalidate" </FilesMatch> <FilesMatch "\.(php)$"> ExpiresDefault "access plus 4 hours" Header set Cache-Control: "no-cache, must-revalidate" </FilesMatch> # Turn off the ETags Header unset ETag FileETag None # Turn off Last Modified Header Header unset Last-Modified
|
phranque

msg:4494420 | 6:27 pm on Sep 12, 2012 (gmt 0) |
my bad - that was the Files directive i was thinking of. i thought the problem was with your subdomain, not your main domain...
|
hottrout

msg:4494449 | 7:36 pm on Sep 12, 2012 (gmt 0) |
The issue seems to be with the main domain as well. I say this because googles page speed test shows images and css from the main site also not having 'Specify a cache validator'. That said to confuse me even more, when I use websniffer to investigate the header info for a gif file on the main website it tell me this :- Date:Wed, 12 Sep 2012 17:14:58 GMT Server:Apache Accept-Ranges:bytes Content-Length:4595 Cache-Control:max-age=2592000, public, must-revalidate, proxy-revalidate Expires:Fri, 12 Oct 2012 17:14:58 GMT Pragma:public Connection:close Content-Type:image/gif This would appear to be correct. What gives?
|
|