1and1 doesn’t have mod_deflate or mod_gzip enabled on its home or business shared server packages which means that many of the usual .htaccess tweaks to compress your web pages won’t work. Here’s something very simple tweaks that will work with 1and1, and with other hosts too.
Set up your .htm and .html files so that they are parsed by the PHP interpreter by adding this one line to your .htaccess file.
AddType x-mapp-php5 .html .htm
Then create and upload a php.ini file to your websites root directory. If you are using WordPress then this should be the same directory as the one where wp-config.php is.
The contents of the php.ini should be as follows.
zlib.output_compression = On
This line causes PHP files to be served as compressed if the browser supports it. And as we have registered .html and .htm as being PHP files they will now be compressed.
You can test that the HTTP compression is turned on by using this simple HTTP compression checking tool, or by using the more comprehensive Page Speed add-on for Firefox from Google.
Here are the results from the HTTP compression checking tool showing that compression is now on, and that the home page HTML is being served using 76% less data. Note that this saving refers only to the HTML page, and not to any other images, style sheets, or JavaScript.
Increasing expiry time of images on 1and1
Another quick tweak you can make to your .htaccess is to increase the expiry time of your images, and other data files. This will result in quicker loading times for regular visitors as the files will stay in their browsers cache for longer.
Add this to your .htaccess. You can increase the expiry times if you don’t think those files will change.
#Increase cache time for resourcesExpiresActive On ExpiresByType image/gif "access plus 2 weeks" ExpiresByType image/jpeg "access plus 2 weeks" ExpiresByType image/png "access plus 2 weeks" ExpiresByType image/ico "access plus 2 weeks" ExpiresByType text/css "access plus 2 weeks" ExpiresByType text/javascript "access plus 2 weeks" ExpiresByType application/x-javascript "access plus 2 weeks"
Use Google’s Page Speed add-on to verify that this has worked. Go to the Resources tab to see the headers for each individual file served from the HTTP server. Below you can see the current date/time, and that the expiry time is set two weeks into the future.
Caching and expiry changes combined
Here are before and after results for Google’s Page Speed tool of applying both the above changes to another of my websites. You can see that these quick changes give the website a small increase in score.
From 88 to 92.
This isn’t a big jump, but it may make a difference. I highly recommend you look at the other performance recommendations from the Page Speed tool, as it can give you loads of ideas for how to make your site faster and more responsive.