Gzipping and setting expire headers with Apache

« Do not stop...   Home   Making a 2D... »

I was running the YSLOW add-on for my site, and the only two suggestions it had was Gzipping content and adding expire dates.

Below is how to do both in your .htaccess file:

AddOutputFilterByType DEFLATE text/html text/plain application/javascript text/css

<FilesMatch "\.(js|css|png|jpg|jpeg|gif|ico)$">
  ExpiresActive on
  ExpiresDefault "access plus 1 month"

Depending on your server configs, you might have to use mod_gzip instead of AddOutpuFilterByType.

The ExpiresDefault syntax is surprisingly readable.