WordPress .htaccess fixes for Page Speed

By | Wordpress | No Comments

I recently finished a job and i am trying to get a score of 100 on Google Page Speed. So far I have fixed a lot of stuff and here are the .htaccess changes that focus on caching and gzip minification.

Header unset Pragma
FileETag None
Header unset ETag

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"

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

<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

# Specify a Vary: Accept-Encoding header
<IfModule mod_headers.c>
  <FilesMatch "\.(js|css|xml|gz)$">
    Header append Vary: Accept-Encoding

How to make MAMP recognize and read server-side includes

By | Coding | 2 Comments

Open MAMP’s httpd.conf (located at /Applications/MAMP/conf/apache/httpd.conf) in a plain text editor.

Uncomment these 2 lines
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

Then using your text editor save as .htaccess on each folder you’re using as a site the following code:
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
Options Indexes FollowSymLinks Includes

If you’re using Xampp open httpd.conf (located at /Applications/XAMPP/xamppfiles/etc/httpd.conf) and then add a new site like this on your vhosts file (located at /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf)

<VirtualHost *:80>
    ServerName localhost
   DocumentRoot “/Users/fernandasampaio/Documents/Sites/www/”
   <Directory “/Users/fernandasampaio/Documents/Sites/www/”>
      Options Indexes FollowSymLinks Includes ExecCGI
      AddType text/shtml .shtml
      AddHandler server-parsed .html
      AddOutputFilter INCLUDES .shtml
      AllowOverride All
      Order allow,deny
      Allow from all

If you’re using Xampp you have to edit your hosts file too. I have a Mac and I use Gas Mask. Windows users can go to: %systemroot%\system32\drivers\etc\hosts