Current time: 12-14-2019, 08:22 PM Hello There, Guest! (LoginRegister)

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inconsistent results? Testing MySQL?
03-25-2011, 10:55 AM (This post was last modified: 03-25-2011 11:19 AM by ckelly06.)
Post: #4
RE: Inconsistent results? Testing MySQL?
Pat, thank you so much for this AWESOME reply. I'm going to get working on these fixes right now.

Quote:Finally, you should make the static pieces of the page cachable by giving them a far-futures expires time (the css, javascript and images). That way the repeat visits will be able to load the images directly from their disk cache and not ping your server to see if each one of them needs to be updated. This is a little more complicated because it requires you to change the file names if you change the contents (add a logo, change the css, whatever) but it is well worth the effort.

One thing that's been challenging since I learned I should be caching static content is that there are NO good tutorials on this on the internet (or so it seems, I certainly can't find one). Actually the most helpful thing I've found so far is another thread on this forum, where I finally learned that implementing this requires changes to .htaccess (none of the other tutorials I found bothered to mention this). Also, looking at an .htaccess file my friend sent me, it looks like he's using the following code for this:

Code:
<FilesMatch "\.(xml|txt|ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public, must-revalidate"
</FilesMatch>

Do you think this code is sufficient, or should I do something more robust like in the thread (code from that is pasted at the bottom of this reply)?

Also, another newbie question. I signed up for a CloudFlare account today (not showing up in results yet, but I think they said it takes a few hours for DNS servers to update). Even if I'm using CloudFlare, it still makes sense to cache static content, right? It sort of seemed redundant if I'm using CF, but I assume that since you break it out as a separate item on the report card, I should do both.

Thanks again!

Chris


Extensive .htaccess code for caching:
Code:
<ifModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html "access plus 1 seconds"
ExpiresByType text/css "access plus 31536000 seconds"
ExpiresByType text/javascript "access plus 31536000 seconds"
ExpiresByType application/javascript "access plus 31536000 seconds"
ExpiresByType application/x-javascript "access plus 31536000 seconds"
ExpiresByType image/ico "access plus 31536000 seconds"
ExpiresByType image/gif "access plus 31536000 seconds"
ExpiresByType image/jpg "access plus 31536000 seconds"
ExpiresByType image/jpeg "access plus 31536000 seconds"
ExpiresByType image/png "access plus 31536000 seconds"
ExpiresByType image/bmp "access plus 31536000 seconds"
</ifModule>
<ifModule mod_headers.c>
<filesMatch "\\.(ico|pdf|flv|jpg|jpeg|png|gif)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<filesMatch "\\.(css)$">
Header set Cache-Control "max-age=31536000, public"
</filesMatch>
<filesMatch "\\.(js)$">
Header set Cache-Control "max-age=31536000, private"
</filesMatch>
<filesMatch "\\.(xml|txt)$">
Header set Cache-Control "max-age=31536000, public, must-revalidate"
</filesMatch>
<filesMatch "\\.(html|htm|php)$">
Header set Cache-Control "max-age=1, private, must-revalidate"
</filesMatch>
</ifModule>
<ifModule mod_headers.c>
Header unset ETag
</ifModule>
FileETag None
<ifModule mod_headers.c>
Header unset Last-Modified

On a sad side note, HostGator just informed me that they don't allow mod_deflate on business shared hosting accounts like mine. Bummer. I don't think I'm ready to upgrade to VPS yet, so I guess gzip is something I'll have to put on hold for now.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Inconsistent results? Testing MySQL? - ckelly06 - 03-25-2011 10:55 AM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)