Jump to content

CDN subdomain: how to sync /img folder ?


Recommended Posts

Hi. I just enable the media server function and created my subdomain on Plesk (cdn1.mydomain.com) . Now the problem is to synchronize the "/img" folder with primary domain, with the cdn subdomain "/img" folder . If I import or add products to shop, images are stored in primary domain "/img" folder, and I have to manually copy files to cdn1.mydomain.com/img ... anyone facing this problem ?

 

Thanks.

Edited by Roberto 84 (see edit history)
Link to comment
Share on other sites

If you have the ability to use the rclone command, you could make a local cron job that repeatedly syncs from your web server's file system to your CDN.  I'm currently investigating this as a viable option.  See https://rclone.org/docs/ .  Something like below.  I've not tried it and I can't offer further help but good luck!

 

#!/bin/bash
rclone sync /var/www/example.com/public_html/img     examplebucket:img
rclone sync /var/www/example.com/public_html/modules examplebucket:modules
rclone sync /var/www/example.com/public_html/themes  examplebucket:themes

 

Link to comment
Share on other sites

Thanks for reply. I can use cron jobs. I was searching for a more elegant solution. Something like an automatic image/thumbs creation directly to subdomain destination when importing products and or modules install. I found another problem with URL rewrite (obviously it rewrite image names for main domain and not for cdn subdomain). Can it be solved with different .htaccess rules changes from main domain ?

 

Thank you.

Link to comment
Share on other sites

As mentioned by @watou, you can try the Sirv CDN addon for PrestaShop.

It's been optimised to sync images, JS, CSS and theme files from PrestaShop to Sirv. Sirv resizes the images, optimises and delivers them from its global CDN in next-gen formats, such as WebP. It also applies lazy loading and it minifies your JS & CSS files. Removing all this overhead from PrestaShop, your server can dedicated more resources to running PrestaShop. It can also delete the PrestaShop resized images, which you won't need any more - saving potentially a lot of storage space on your server and lowering your hosting costs.

If your goal is to get the best possible performance and PageSpeed score, these are the best-practices which Sirv applies:

  • Serve images in next-gen formats
  • Use lazy-loading
  • Optimize images
  • Serve scaled images
  • Use a Content Delivery Network (CDN)
  • Leverage browser caching
  • Minify CSS
  • Minify JavaScript
  • Minimize request size
  • Enable compression
  • Reduce DNS lookups
  • Use cookie-free domains
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...