Explanation of what CDN's do with "cached" resources? - cdn

I use shared hosting in conjunction with the CDN Cloudflare. And, my site is definitely faster than before using the CDN. However, I'd like to have a better understanding of how the CDN and my hosting service interact. For example, suppose I have an image on a webpage, as well as an external javascript file. I know that the CDN "caches" these resources. But, does that mean that instead of transferring the image/javascript from my shared hosting (which would "cost" me bytes transferred each month), that the CDN does it, essentially give me "free" transfer of these resources?

Yes, you are right if your CDN service provider doesn't charge any data transfer fees (such as free level CloudFlare).
Basically what happened is a user make a request to an asset in your website, if that item is already being cached in your CDN provider's edge node, the item will be served from them.
The only time your server will get a hit is when the asset is not available from the cache or expired.
But this free does come at a cost, there is no free meal and imagine how CloudFlare can survive if simply allow every one to have a free meal.
For most of the free service, there is no performance guarantee so that the cache hit ratio may not be high all the time, CDN provider may only allocate a limited memory to store the cache for free customers, hence there is a relatively higher chance that your assets are not available in the cache.
What's worse is if the content is not available in the cache, then your CDN provider will need to fetch the file to your origin server. Now a direct request from end user to your webpage becomes two indirect request, which obviously will actually increasing the loading time.

Related

Do CDN prefetch user's static data or it's done on the request?

As per Akamai -
A content delivery network (CDN) is a group of geographically
distributed servers that speed up the delivery of web content by
bringing it closer to where users are. Data centers across the globe
use caching, a process that temporarily stores copies of files, so
that you can access internet content from a web-enabled device or
browser more quickly through a server near you. CDNs cache content
like web pages, images, and video in proxy servers near to your
physical location. This allows you to do things like watch a movie,
download software, check your bank balance, post on social media, or
make purchases, without having to wait for content to load.
So I am mainly interested in "post on social media"
Will the CDN prefetch a user's social media content (static?) or will it be done at the user's request because prefetching can be costly, complex and wasteful?
Prefetching generic static information, such as a website's landing page image, a viral video, product images (amazon must use CDN to deliver images for their products else it will take lot of time to load images and will be a very bad experience) makes sense.
Whether it is social media content or a static website, content is not fetched by Akamai except when a request comes to the platform for the content. At that point, depending on how the platform is configured for your particular site, the content is cached for later users for a period of time.
A few notes:
Akamai can be configured to automatically request the additional content linked on the page without waiting for the end user's browser to issue the request. Details: https://techdocs.akamai.com/property-mgr/docs/prefetching
You can use prefetching for both cacheable and non-cacheable objects. Details: https://techdocs.akamai.com/property-mgr/docs/prefetchable-objects
You can configure Akamai to prefresh that content as it nears the expiration of the caching time limit, checking to see if it has been modified. Details: https://techdocs.akamai.com/property-mgr/docs/cache-prefresh-refresh
In the case of user profiles, for example, I would not use caching. Synchronizing all the data to keep it up to date is complicated.
CDN systems usually let you set whether to cache the file and how often to update it.

http:// website not loading for old users

I recently moved a website from https://www.ezacu.com to http://www.ezacu.com and I'm finding that the website loads for people who have never visited the https version, but not for people that have.
I believe that this is either because their browsers keep autocorrecting http to https (since it used to be https) or because their browser is trying to use a cached version. Im not sure how to find out or how to fix the issue, but it is especially difficult for me because it works on my computer/phone; The issue is with other users.
I am hosting the website on amazon S3
The simple solution is to create a CloudFront distribution with your domain name as its Alternate Domain Name, attach a free SSL cert from Amazon Certificate Manager, type the web site hosting endpoint from your bucket as the Origin Domain Name (don't select the bucket from the drop-down list -- that won't enable the web site hosting features of S3), then point your DNS to CloudFront.
When you use CloudFront with S3, you pay bandwidth charges to CloudFront instead of to S3, so the cost difference is negligible and in certain cases, bandwidth can actually cost slightly less.
There isn't a way to convince browsers not to try to use HTTPS once they believe it's available.

What happen when user location is near the Origin server more than CDN server?

When we use CDN, provider say that users will get static content on nearest server for faster loading speed...
But if users location is near the origin server more than CDN server then what happen?
Users will get cached content from CDN server or they will get content from Origin server? And what case will be faster?
(My case is that Origin server based in my country, I want users from global can access my site faster, but these big CDN providers does not have server in my country, I fear that users in my country will get slower loading speed compare to when I don't use CDN...)
If you switch to using a CDN, then all your users will go through the CDN. If they don't have a server near you, then it is going to be slower for your local users. It's up to you to make a call on whether that tradeoff is worth it to gain the speed improvement for the international users. If you're mainly expecting local users for now, I would say you should avoid using a CDN for the sake of it.

implications of having a site in full https

I am currently developing an MVC4 web application for eCommerce. The site will contain a login and users can visit the site, input their details and submit orders etc. This is a traditional eCommerce site.
To boost the security of the site, I am looking to set up the entire site in https. As the user will be supplying their log in credentials and storing personal information in cookies, I would like the site to be fully secured.
I have concerns though, these being if I set up the site in https, will it detriment performance? Will it impact negatively on search engine optimization? Are there any other implications of having an entire site in https?
I use output caching to cache the content of my views - with https will these still get cached?
I have been reviewing security guidelines and documentation, such as this from OWASP and they recommend this. Also, I see that sites such as twitter are fully https.
Generally speaking, no - whole-site encryption is not a problem for performance.
(Just make sure you disable SSL 2.0 on your server, as it's vulnerable to the BEAST attack; you should use TLS 1.0 or SSL3.0 which have been supported by pretty much every browser since 2000).
The performance issues were a problem years ago, but not anymore. Modern servers have the capacity to deal with the encryption of hundreds of requests and responses every second.
You haven't mentioned deploying a load-balancer or failover system, which implies your site won't be subject to thousands of pageviews every second. That's when you need to start using SSL offloaders - but you're okay for now.
Output caching is not affected by encryption - just make sure you're not serving one person's output to another (i.e. cache a shopping cart or banking details in Session or with the Session ID in the Cache key).

Why do we need CDNs when HTTP proxies already cache content?

CDN seems to be a popular way of improving an app's performance.
But why are they required when you consider that HTTP proxies on the web can cache the content already ?
CDNs are a kind of web cache, just one operated under your auspices, rather than the web user's. You get full control of the freshness of your content, whereas you don't have any control of the proxy servers "out there".
The user's proximity to your web server has an impact on response times. Deploying your content across multiple, geographically dispersed servers will make your pages load faster from the user's perspective. But where should you start?
Read full article at https://developer.yahoo.com/performance/rules.html

Resources