Slow load in prestashop
Slow load in prestashop
This is my second article I’m writing about this Ecommerce script, the old article was specifically written for prestashop slow speed in version 1.5 that just launched, but I’ve seen that a lot of users are accessing the old link and still having issues. Why am I doing this? I figured is best to have it nicely as a step by step guide using images and also I found a nice little trick to rely on browser cache to speed this even more, this will reduce the page load to your visitors when they will access the same page in, say 600 seconds or so (you an choose the timeout). I’ve seen a lot of issues so far with prestashop, site being slow, or just slow load on prestashop frontend. It is true that it needs to parse the php page, however, since it has a caching mechanism, you would think it would cache the pages? Nope, these are still parsed it seems … indeed its wrong, but can’t help it …
Anyway, lets get started. Compared to last time, I’ll try to explain step by step how to optimize your website.
1. SEO & URLs
Although this doesn’t really falls in the optimization part, it does help when caching the pages. Compared to using page names with lots variables which are hard to cache, it is better to cache .html or .htm pages for example.
This can be done directly from section Preferences / SEO & URLs
You will need to check the Friendly URL and, if using special characters, Accented URL. The rest can be left as they are and click the Save button. Now some of you will see there an error that mod_rewrite is not active on the server, that’s really a bug in the script, mod_rewrites works nicely and without errors, even prestashop is rewriting the URLs normally. So just ignore that message, unless for you it really doesn’t work. At that point, check to see if you have the .htaccess file on your account or contact your hosting provider.
2. Smarty cache
We can now start with the exact settings for properly caching the pages. First go to Advanced Parameters / Performance
First we have Smarty Cache, check the following options:
- Never recompile template files
- Check Cache
- Do not open console
3. CCC (Combine, Compress and Cache)
This is also important, since we no longer use smarty compile as it was before deactivated, we only need to check:
- Use CCC for CSS
- Use CCC for JavaScript.
- Keep HTML as original
- Keep inline JavaScript in HTML as original
- Check Apache optimization
4. Ciphering
This I usually leave it by default:
- Use Rijndael with mcrypt lib.
5. Caching
Lastly we have the caching mechanism, if possible, try using memcached, APC or Xcache, if your hosting service does not offers this, you can use the normal File System cache.
- Check Use cache
- Caching system : File System
Of course, next is the CDN option, you can also use a CDN for speeding up and caching even more, I found MaxCDN and Cloudflare to be really great and cheap (Cloudflare free).
6. Implementing browser static cached file for prestashop
Its a fancy name, but its really just some .htaccess rules with some expire and caching headers. Se bellow:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<ifmodule mod_mime.c> <filesmatch ".html.gz$"> ForceType text/html FileETag None </filesmatch> AddEncoding gzip .gz AddType text/html .gz </ifmodule> <ifmodule mod_deflate.c> SetEnvIfNoCase Request_URI .gz$ no-gzip </ifmodule> <ifmodule mod_headers.c> Header set Vary "Accept-Encoding, Cookie" Header set Cache-Control 'max-age=3600, must-revalidate' </ifmodule> <ifmodule mod_expires.c> ExpiresActive On ExpiresByType text/html A3600 </ifmodule> |
Open the .htaccess file inside your document root of your website and add the above lines just under your existing .htaccess rules.
With this you set a timeout of 3600 seconds on each resource request from your website, on next request of the same page, the user will use the pages from their browser cache and he will also be happy that the page is loading faster.
More information on these tweaks can be found on this page were I wrote more how you can cache your pages using browser cache, you can play even more with this if you wish.