Jump to content
  • 0
mozack

Using CDN with prestashop

Question

Hi, to all

 

Recently i started using Amazon CloudFront as cdn. I put the address in media server and everything is working (almost fine).

 

Here is my questions regarding that:

 

1 - How to update the themes/mytheme/cache files when they are updated? I think the CDN reload the file every time he changes, but prestashop must change the file name or something like that.

 

2 - How to auto load the css, js and images from modules folder to be loaded by cdn too?

 

3 - How to make the images with expiration date?

 

I saw some of CDN servers and we should have more flexibility to edit and update important files like that. Some of the ecommerce script available in market use something like myfile.css?12345, this is usually updated via file last update which force cdn to reload that file.

 

Hope someone can help me with this 3 little questions...

 

Regards

 

Mozack

Share this post


Link to post
Share on other sites

38 answers to this question

Recommended Posts

  • 0

Hi,

 

We've been trying to implement the Media Server feature but have not gotten this to work, and it seems like we have tried everything. There is no solid documentation on how to use this feature.

 

We discovered Amazon CloudFront and would really like to use them as CDN and set it up as our media servers... it seems like you have been able to get this working, which is great! Would you mind sharing how you set everything up and how it works??

 

Thanks so much!

Share this post


Link to post
Share on other sites
  • 0

Did you guys ever got your CDN working for your stores? Also, how did this improve your site loading speed?

 

I am starting to look into CDN to give customers a low latency for website browsing.

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

Haven't set this up yet... but I did sign up for Amazon's CloudFront. We've been upgrading our site most of today, so once we get the finishing touches done this is our next step. Hopefully, by tomorrow or the next day I will have a chance to at least try and set this up.

 

Will report back.

Share this post


Link to post
Share on other sites
  • 0

Ok... so real quick. I think we managed to get this up and running... CDN using Amazon Cloudfront.

 

It was actually very easy... but we are going to test further. But as a prelim here is how we set it up.

 

You need to sign up for Amazon's AWS service... it's free and you only get charged for the services you use.

 

For this purpose, you need to have CloudFront available. Nowadays, if you sign up for one of their other services, this service should be available. IE. If you signed up for S3 or EC2 the CloudFront service should be available. Click on the "CloudFront" tab. If the service is available you will be able to create a "distribution" otherwise it will have different link asking you to sign up for this service, in which case, go ahead and sign up and then go back to the tab to create a distribution.

 

It will give you a series of fields that need to be filled out... some are optional and you can find more details by hovering over the title of each field. Basically, we set ours up to orginated from our server (that does not run off of EC2 or S3)... so we selected "custom origin" then entered our domain name. We allowed connections for both HTTP and HTTPS... added no CNAMEs (going to use the one automatically generated by Amazon). Entered nothing for Default Root Object (later we might test with index.php as this field, but nothing for now). Logging is set to off... if enabled you will need to link it to an S3 bucket (so you have to sign up for this storage service also). Then selected "Enabled" for the distribution status. Very easy... then finish by saving or creating the distribution.

 

Once this is created and enabled... you will see it in the list. You will see a column titled "Domain Name" we just copied this domain name (something similar to xxxxxx.cloudfront.net). Then we went to our BO... Preferences tab >> Performance >> scroll down to Media Servers. BTW... you need to enable the CCC options to take advantage of this feature. So enable CCC from above then for Media Server 1 paste the Amazon cloudfront domain name and click save.

 

Go to front office and reload the page... at the bottom left corner (or right corner) you will see the loading status of the page so if set up correctly, you should see the Amazon cloudfront domain name as it loads your homepage.

 

Again, we need to test further, but initial signs shows that it is working... oddly, our PageSpeed stat is lower/worse with this enabled. I think we need to tweak some of our settings... maybe regenerate our .htaccess file and tweak our server.

 

HTH!

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

Actually it was very easy to setup... i just went into a lot of details. Just sign up, answer a few questions to create a distribution, and then copy the domain that is automatically generated Amazon into your Media Server 1 field in the BO. Save and done and done.

 

Cost... not sure yet... according to Amazon's site it says the first 10TB is rated at 0.12 cents a GB. And then the next 40TB at .08 per GB, and so on. I should have a better estimate at the end of this next month.

 

HTH!

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

Sorry... since our recent update, we've been making minor adjustments to our site, so to do efficiently we have disabled the PS performance features temporarily.

 

Just a word to the wise... we noticed that when making adjustments with performance features on some changes were not immediately reflected even after a clearing the cache. We noticed that the CDN was serving cached versions of our images and static files, so to make proper, immediate adjustments you may want to disable these features for the time being. If you change the names on the files (which isn't often) then it's ok... but for example images if you adjust the size but upload it using the same name than the change won't take affect im guessing until the cache of the CDN is refreshed. On the bright side, at least we know the CDN and performance features are working!

 

And YES, you will see a cloudfront.net address in the status when the pages are loading... that is of course, after we re-enable these features. We hope to have this enabled again by later today/tonight.

 

HTH!

Share this post


Link to post
Share on other sites
  • 0

Not a dumb question at all... quite frankly I still am not 100% sure how it works. BUT... no I did not have to upload anything to my server or to CloudFront.

 

Basically you set up the distribution on Amazon's side, then you tell PS via the BO the media server domain name (aka amazon cloudfront distro) and that's it.

 

It appears PS is set up to automatically do it's thing as far as serving images and static files via the defined media server(s).

 

I remember somebody saying (in a different post) that some files were not included in the CDN (ie. media and static files from third party modules, etc)... so it appears that PS's code has a set of specific folders that it tells to serve via CDN if that feature is properly set up. I'm still trying to figure out if all my static content is being served through cloudfront (highly doubt it), but in any case I do know that a good amount of content IS properly being served over the CDN. For example, I can see the cloudfront address serving content when a page loads, and my product images point to my cloudfront distro and not directly from my domain as before.

 

HTH!

Share this post


Link to post
Share on other sites
  • 0

Hi,

 

Why don't you take a look at the CDN article ?? Full content link: http://prestashopexchange.com/articles/cdn-or-not-should-i-use-cdn/

 

 

 

 

 

EDIT

 

 

 

Table Of Content

 

Introduction

Should I use CDN?

How CDN works

The Request Cycle

How does CDN invalidate cached objects?

Performance Impact

 

What would slow a Prestashop e-commerce site down?

Is CDN the answer to performance?

Increasing shop performance

Move off shared hosting

Optimizing PHP, Apache and MySQL

 

Final words

 

 

Introduction

 

This article steams from a user question about the use of CDN and related questions around the CDN topic. The question is actually very simple but the, user, like many other Prestashop site owners, do not realize that there are more important ares needs to be considered before adopting a CDN. In this article, we will discuss whether or not CDN is appropriate for Prestashop e-commerce sites, alternatives to CDN and background technical knowledge

Should I use CDN?

 

This is probably not the first question Prestashop owners (shop owners) ask when starting an online shop, but will definitely be the one of the most popular questions shop owners ask themselves when the following happen:

  • Growing amount of traffic, and predicted that additional capacity will be required in the near future.
  • Obvious degrade in performance, especially during peak trading hours.
  • Sometimes it is even worse, the whole site simply stop responding or takes too long to respond.
  • Exceeding bandwidth limit, and the ISP is charging a lot of $$ per GB.

The most obvious answer to the above seems to be Media Servers (or CDN) for PrestaShop owners. Since this is readily available from the Performance configuration screen, but how does it work? How will CDN improve the performance of your site? And more importantly, does it really helps and do you really need it?? Read on and find the answers below.

Share this post


Link to post
Share on other sites
  • 0

you just don't understand, isn't it? have you looked at the content of the link? It has the full request life cycle and I don't call this technical. You don't need to move / copy images because this is dealt with automatically. Please do not use "what you have seen" to try and understand something much more complex than you think.

 

When I say technical details, I mean multiple edge servers / global load balancers / firewall / distributed caching / DNS with Geo Location, etc, etc.

 

Are you after the details of how the entire infrastructure can be implemented? Or do you call using SFTP to upload files "technical"?

Share this post


Link to post
Share on other sites
  • 0

This sounds exactly what I'm looking for. Couple of questions.

 

1. what version of prestashop are you running?

2. so you didn't need to transfer any file to

Amazon CloudFront

 

To confirm. You signed up. entered the media address and all worked?

 

3. did it work

immediately

4. how many media servers did you use, all 3 or just one?

Share this post


Link to post
Share on other sites
  • 0

Not a dumb question at all... quite frankly I still am not 100% sure how it works. BUT... no I did not have to upload anything to my server or to CloudFront.

 

Basically you set up the distribution on Amazon's side, then you tell PS via the BO the media server domain name (aka amazon cloudfront distro) and that's it.

 

It appears PS is set up to automatically do it's thing as far as serving images and static files via the defined media server(s).

 

I remember somebody saying (in a different post) that some files were not included in the CDN (ie. media and static files from third party modules, etc)... so it appears that PS's code has a set of specific folders that it tells to serve via CDN if that feature is properly set up. I'm still trying to figure out if all my static content is being served through cloudfront (highly doubt it), but in any case I do know that a good amount of content IS properly being served over the CDN. For example, I can see the cloudfront address serving content when a page loads, and my product images point to my cloudfront distro and not directly from my domain as before.

 

HTH!

 

Hi! Do you have any new suggestion since it's passed a while? :)

 

I've just configured CDN following your advices on CloudFront and seems to going well.

 

Did you made 3 copyes of the same domain and then put the domain name that CloudFront gives to you into the CCC boxes or you did something different?

 

Also, anyone knows how to set more than 3 CDN with that system?

 

Thanks!

Share this post


Link to post
Share on other sites
  • 0

I am about to have this set up i hope in the next few days and if I have any new info to add I will update this topic to help others out as well. I tried to use memcache but that is one program i do not like at all!!! slowed my site to open between 6 and 8 seconds which is unreal when i disable it pages open in 0.2 to 0.4 seconds to much of a difference and easy for me to decide to use another program so i have decided on Amazon aws.

 

Clayton

Share this post


Link to post
Share on other sites
  • 0

I have just set up Cloudfront as a CDN and thought I would chime in with my findings.

  • Set up Cloudfront first - create a distribution and save it, then wait until your entire website has been deployed (the status will change).
  • Once it has deployed, then add the CDN domain name (from the AWS control panel) to the BO>Advanced Parameters>Performance >Media Servers and save.
  • If you do that before your site has finished replicating through Cloudfront, you won't be able to deliver images.
  • The same goes if you make major changes - turn off CCC/Media servers before you make the changes, make the changes, refresh your CDN through the AWS control panel, once it has finished replicating, turn your CCC/Media Servers back on again.

You can check whether it is working properly by (in Chrome, at least) loading your website and then viewing the source (View>Developer>View Source) - you should see all your static content addresses changed to something.cloudfront.net

 

One reason I am using Cloudfront is my customer is in New Zealand but my web servers are in New York. The price of webspace in NZ is prohibitive and apart from the delays loading static content, the performance was pretty good. So, using CF as a CDN is a great option.

 

They have a calculator that enables you to show your projected costs. http://calculator.s3.amazonaws.com/calc5.html

 

Go to the right hand side of the calc and look down the list till you see CloudFront - choose your bandwidth and locations.

 

As an example, I chose 10% Singapore/Korea and 90% Australia (which replicates what my customer sees from their geo stats) at 10BG/Month comes to $1.90

 

A really cheap way to boost performance and still comes in at half the price of a shared web server in NZ, including CDN and NY-based web server.

Share this post


Link to post
Share on other sites
  • 0

Well, it does and it doesn't :)

 

After a lot of mucking around, I am confident the problem isn't in the loading of images - it's in the initial response to the request. In my case, sometimes up to 12 seconds before the web site delivers the first byte back to the browser.

 

There's a lot of shit on the forums about slow web servers, so I set up a Wordpress e-commerce site using my same account, just in a subdirectory. The WP web returns its first byte in about 200msec. The Prestashop one, 9-12 SECONDS.

 

There is something seriously wrong with this software and I am really, seriously regretting ever having adopted it, but now I am at a place where it would be extremely difficult to back out. I've spent tens and tens of hours of development and product loading, customizing, etc and to have to back that out to a different platform would be a real problem.

 

I have had it so I got the entire web page loaded in 9 seconds, which at the time seemed really fast, but that was only because it was so slow before. I have stripped it all back - no CDN, no multiple-subdomain config, and am working on getting it as fast as possible under that, then I will performance test with various flavors of CDN.

 

My advice to you is to do the same - look at the native performance and once you have that working acceptably, then look to external performance boosters.

 

I'm sorry I couldn't be of more help.

Share this post


Link to post
Share on other sites
  • 0

I am trying to add amazon CDN on my media servers (CCC) on pestrashop but images are not comming. what can be the issue? please tell me.

 

thanks in advance!

Share this post


Link to post
Share on other sites
  • 0

I am getting below error when I am trying to open image URL.

<Error>

<Code>NoSuchKey</Code>

<Message>The specified key does not exist.</Message>

<Key>img/p/6/9/69-home_default.jpg</Key>

<RequestId>4FE37C593FDF381A</RequestId>

 

 

<HostId>

BEBk6wAuIzPN9w5pix+b0/pye6XGPRn7VW6Ik9O0xPS88RGize3i2DVr2feGkM+1

</HostId>

</Error>

Share this post


Link to post
Share on other sites
  • 0

Well, it does and it doesn't :)

 

After a lot of mucking around, I am confident the problem isn't in the loading of images - it's in the initial response to the request. In my case, sometimes up to 12 seconds before the web site delivers the first byte back to the browser.

 

There's a lot of shit on the forums about slow web servers, so I set up a Wordpress e-commerce site using my same account, just in a subdirectory. The WP web returns its first byte in about 200msec. The Prestashop one, 9-12 SECONDS.

 

There is something seriously wrong with this software and I am really, seriously regretting ever having adopted it, but now I am at a place where it would be extremely difficult to back out. I've spent tens and tens of hours of development and product loading, customizing, etc and to have to back that out to a different platform would be a real problem.

 

I have had it so I got the entire web page loaded in 9 seconds, which at the time seemed really fast, but that was only because it was so slow before. I have stripped it all back - no CDN, no multiple-subdomain config, and am working on getting it as fast as possible under that, then I will performance test with various flavors of CDN.

 

My advice to you is to do the same - look at the native performance and once you have that working acceptably, then look to external performance boosters.

 

I'm sorry I couldn't be of more help.

 

i am getting 1 to 4 secs for TTFB. Which I had already tweak them by a lot.

your 9-12 sec is TTFB or loading time?

 

my total loading time is around 6-12 sec

Share this post


Link to post
Share on other sites
  • 0

can you pass me your email address so I can send my site info please ?

 

you can put your link like mine. :) so it will not be in the SERP.

 

anyway the link that we all placed here are no follows too. :)

Share this post


Link to post
Share on other sites
  • 0

i am getting 1 to 4 secs for TTFB. Which I had already tweak them by a lot.

your 9-12 sec is TTFB or loading time?

 

my total loading time is around 6-12 sec

 

12 secs is (sometimes) TTFB - I can guarantee 9 secs TTFB, but my Wordpress site on the same hosting account - 200msec TTFB.

 

If I remove all modules, I can get it to around .5-1.5 seconds.

 

As I add modules, stays the same until I add something like 'new products', then it drops straight away to 4-5sec TTFB, add another couple of modules and it drops to 9.5-12 TTFB - complete page in something like 20-22 seconds.

Share this post


Link to post
Share on other sites
  • 0

I am going to do a trial with a 7-day VPS and see if the problem is just shared hosting. I have installed it on my Mac OS webserver at home and it is pretty fast.

Share this post


Link to post
Share on other sites
  • 0

Who's your host? I am hosted in Singapore as well, with Siteground.

 

I am in Brunei, my customers are all in NZ and Australia...

Share this post


Link to post
Share on other sites
  • 0

@zootalaws whilst prestashop is great, yes it is a bit slow. surely its a case of some small configuration of the first file that loads, or js rather than using another shopping cart. i love presta , but yes if i could get it faster, that would be better but i dont think it would have to be 100% change in the code for faster speed, surely just a few lines of code here and there, or maybe im wrong :(

Share this post


Link to post
Share on other sites
  • 0

do you need to fill in all 3 media fields or just the 1?

I think the CDN does everything, so you dont have to copy files, move anything, etc. i'm on a hosted server and am going to try either cloud fare or amazon. anything to help speed up websites will hopefully generate more sales!

thanks everyone for your input!

Share this post


Link to post
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

×