Moodle very slow

moodle logo

Make sure you take your websites backup before implementing any of these tips. 


First of all here is the best tool to test your site performance as far as Pagespeed is concerned.It is the Google’s own pageSpeed Insights.

This tool will not only show you how you are ranked but also tell you how to fix problems. Related to browser caching and how to eliminate render-blocking JavaScript and CSS in above-the-fold content and more.

If there is server related issues and the response time is more than 200ms you can try these suggestions : First discover the reason behind this slowness.

Moodle CDN
Avoid placing too many images on main page, it is advised to use CDN for this purpose. There are multiple services like CloudFlare, Incapsula, Google PageSpeed Service and all work well, i would have certainly advised Google pagespeed but it has been discontinued  on August 3rd, 2015. It was really easy and good to understand and implement.So now my second most and best option would be Cloudflare. I have used it in past. You can find cloudflare in your CPanel. If you offer video tutorials you must do it. A user from Warriorforum stats that the page load time dropped significantly to an average of between 200ms-600ms after using CloudFlare (Make sure you keep your security level to low) otherwise it would be annoying for website visitors to put a captcha every time they visit your site.

For video tutorials

There are few CDN’s that also offer video content delivery like Amazon cloudfront Free version includes AWS Free Tier includes 50GB data transfer out, 2,000,000 HTTP and HTTPS Requests.

: It would be ideal for those with video content to stream videos using such CDN’s other options are Alfresco,, Flickr, Google Docs, MERLOT, Picasa, Recent Files, WebDAV servers,youtube etc. Here is the suggested thread about it.

The problem with youtube and other public video hosting sites is that you can’t prevent them to be downloaded by people using tools like youtubedownloader

GZIP compression

Now here is the real working tutorial that one should try

GZIP – the pages

How to do it ?
In a shared hosting website just like most of us you have to login using ftp and then look for php.ini file in the root folder. If you are unable to find php.ini make sure you have enabled “show hidden files” option from ftp, or in other case you can login using the Cpanel and then click on file manager >> now before clicking on your


Now you have to enable ZLIB compression by adding these lines in this file


zlib.output_compression = On


zlib.output_compression_level = 6

The value can be from 1-10, 6 is common so used here.


Now to compress css and javascript add following lines in your .htaccess file (APACHE server)

AddHandler application/x-httpd-php5 .php .css .js


Now download this file and place it in root folder


After placing the file add these lines to your php.ini file

auto_prepend_file = /full/path/to/prepend-moodle.php

make sure that path is given to that file. Thats it now to check how much your files are compressed run this online gzip test you can also use Live HTTP Headers to examine the response.




Here is another method to enable output compression in a easy way try adding this to your .htaccess file.

# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE



If you have any problems related to images loading or so better reverse the edits.



References for further clarification

for advanced users try :




  • Thanks for the great post.

    A note on the compression section. The php zlib compression tends to have problems with some page in Moodle. I recommend using the second approach in your block which uses mod_deflate.

Enjoy this blog? Please spread the word :)