Perch and SSL

Google have announced that serving sites over SSL may give you a ranking benefit. If you decide to switch some or all of your site to be served via SSL Perch makes it easy for you to manage that.

To start using SSL in Perch you first need to add a line to your config file:

define('PERCH_SSL', true);

Unless this line is there any calls to force SSL will be ignored. You can use this to your advantage during development. If you use our technique for multiple environment config files you can add the PERCH_SSL option only to your live environment, and you won’t get errors due to a lack of certificate locally.

Forcing a page to be delivered via SSL

Directly after the Perch runtime include add the following:

<?php PerchSystem::force_ssl(); ?>

This will force the page to be delivered via SSL. If you want most or all of your pages delivered via SSL then you could add this to an include that is added to all of your pages – just make sure it is included before anything is output to the browser.

To force a page not to be SSL

Use the following if you want to prevent a page from being displayed using SSL.

<?php PerchSystem::force_non_ssl(); ?>

You will take a performance hit by serving your entire site as SSL, and if you rely on a cache such as Varnish you should be aware that Varnish doesn’t cache SSL pages. It remains to be seen whether all things being equal a highly performant site is going to rank better than an SSL delivered site. Using a CMS built with speed in mind does protect you to some extent of course!