Media Protection causing slow down of site loading

Media Protection add-on is not working well with my theme (videoflix by CactusThemes), when this add-on is enabled the load time is huge.

  • Soumendra Mishra

    Hello Marc David,

    Thank you for contacting us today and sorry for the issue you are facing.

    I have tested the issue on my installation. And I've noticed the page speed is too slow when both the "videoflix" theme and the "Media add-on" are activated.

    I've checked that by installing a different theme (not default theme) on my installation and the page load difference is not that much.

    Also, I'd like to mention that activating media protection will increase the page speed a bit as per it's nature. But there is a lot of time difference between the default theme and with the theme you have used(videoflix) which is not natural.

    I'm forwarding this to our development team so that they can check if there is anything we can do from our end. Also, please get in touch with your Theme Developers so that they can check if there is any fix from there side.


  • Panos

    Hi Marc David ,

    The way this type of protection works is to replace media urls to protected ones in front page content. This happens in the front end, as shortcodes may use ids instead of urls.

    The process of replacing the urls in front end, could cause such delays as in your case, especially when there are many images in a page. The replacement does a db call and some calculations in order to fetch correct masked url. Such operations have significant impact on load time.

    An alternative would be to replace those images in post content when post is saved. This way it would load the masked images directly from content and there would be no need to scan content and replace each image (so no delay). However, any image that is not in post content (eg in header, footer etc) will not be masked. Also if the image id is used, for example in gallery shortcode, then it will also not be masked. So this is not a valid solution in my opinion.

    One other way would be to use the wp_get_attachment_url and wp_get_attachment_image_src filters. I have already done several tests with those, but still the delay is the same.

    I have pinged lead developer for his valuable input, so we can see if there is any way of improving the load time and I'll update you once I have news.

    Until then I would suggest to use a caching plugin (eg Hummingbird) so it doesn't have to load page content each time. It will, instead, load the cached page, so there should be no delay there.

    Kind regards!

  • Panos

    Hi Marc David !

    Thanks for your feedback! It seems Hummingbird's cache is conflicting with something else on your site. The served page is not the cached, although I do see the cached paged in wp-content/wphb-cache/cache/ directory.

    Also the headers seem to be wrong too:

    Cache-Control: max-age=3, must-revalidate
    Cache-Control: max-age=0, no-cache

    I wanted to add some checkpoints to see if the part that serves the cached output is reached or not via ftp, but it seems I don't have enough permissions to save files.

    I would suggest a plugin conflict check to see if there is some plugin interfering there. With your permission I could do that. I will disable most plugins and switch to a default WordPress theme. Of course it might be something else, but it's worth the check.

    Kind regards!

  • Panos

    Hi Marc David ,

    Apologies for taking so long to reply!

    I tested Hummingbird again, and for a few times it would load site fast but then it started loading slow again. That happened without de-activating any plugin, so it seems it's not related to plugin conflict.

    I noticed that when trying to Clear cache, I get a warning message related to permissions. I'm not sure it's relevant but it's an indication that something might not be set correctly in server configuration.

    Something else that I can't explain is that there are cached pages in folder:
    with different domains. These could be pointing to you site but there could be many explanations about that. Just wanted to let you know, as those folder names seem suspicious.

    I have modified a file in membership plugin, which uses transients to store content. So if the transient exists, it would load that, so it would not repeat the calculations on next loads. First load would still take time though. I couldn't replace this file on your server since I don't have enough permissions to do so I ma attaching file here.

    File path is:

    I would suggest to keep a backup of original file before replacing it. You can simply rename it to class-ms-rule-media-model.php.txt for example.

    Then do a few tests and check if there is any improvement in load time.

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.