How Akamai cache works - Bug Reaper

                  Bug Reaper

Lean about Automation Testing,Selenium WebDriver,RestAssured,Appium,Jenkins,JAVA,API Automation,TestNG,Maven, Rest API, SOAP API,Linux,Maven,Security Testing,Interview Questions

Sunday 19 April 2020

How Akamai cache works

We use cache to retrieve the resources and reduce the load on servers in finding the required resource.

Frequently used resources are good for considering to be cache

HTTP has Cache-Control header

Cache-Control: max-age=<seconds>
Cache-Control: max-stale[=<seconds>]
Cache-Control: min-fresh=<seconds>
Cache-Control: no-cache
Cache-Control: no-store
Cache-Control: no-transform
Cache-Control: only-if-cached


no-cache
Caches must check with the origin server for validation before using the cached copy.

no-store
The cache should not store anything about the client request or server response.















There can be various places to store cache

4 Levels of Cache

1.) Like at Server level or Load Balancer

2.) But if we store cache at CDN it can be of good use as request will come to nearest server of CDN and request won't be required to go actual server, which may take time if the server is at distant location

3.) We can also cache at ISP level, if 2 persons are downloading the same content, ISP can cache the response and serve to both users, avoiding to go to CDN over and over again

4.) We can also cache at Device or at Browser, which is more faster than above all three.

Akamai Caching at Luna Control Center





So here Akamai Options tells what to cache, it will look into HTTP header of your request which Server serves first time and

then these options of Akamai comes into picture and Akamai will cache the content based on the above options

You have to mention TTL if your server doesn't return above HTTP headers

Note: There is also one more option "no-store", which means all the dynamic content from the server like HTML and API calls will be loaded and nothing would be stored in Akamai cache

0 TTL vs No Store

In case of No store all the calls from Edge Server will go to main Web Server

In case of 0 second  TTL all the calls from Edge Server will go to main Web Server but will check if the content is modified or not, if its 304 code i.e. Not Modified


If its not modified , Akamai cache will return the cached response and thus will save bandwidth as in this case it didn't fetched the whole payload from Web server but returned the cache response only

Cache Keys

Its a unique string that tells Akamai Edge server to look for content when you hit them

Origin/path/filename

Example
www.acme.com/assets/banner.png


What are the features Akamai provides to control Cache Key

We can have ignore case

Cache key Query Parameters





You can include or exclude the parameters from the options if URLs are similar

Purging Cache


Why we need to delete the cache

1.) Might be corrupted
2.) Might be not updated


To get rid of that file we use Purge File

Ways to Purge

1.) Method DELETE, this will delete all the files from Edge Server
2.) Method INVALIDATE , here Edge server checks with Origin Server, if the file needs to be replaced or not based , if both the files are of Same Date or Time Stamp, no need to Invalidate the file from that Edge Server

Note: DELETE can put more load on Origin Server then INVALIDATE, because in DELETE you are asking Edge Server to Delete and get a new copy from Origin Server

Another point is AKAMAI Edge Server will keep serving the "Stale Data" from Edge Server to End User in case you try to INVALIDATE the Edge server and Origin Server is unreachable

Fast Purge

Purge Content By:


URL
CP Codes
Cache Tags (you can Tag all the contents from Pages, like Home Page can be tag, where you mention these contents of Home Page I would like to cache), so When you purge by HomePage Tag , all content that was cached from HomePage would be purged
ARLs (Cache Keys)


Example:
purge delete --tag homepage

Question
 How to purge the content in case of Continuous Pipeline

There is API for that , we can use that for purging the content in case of Continuous Deployment


Web Security

Best part of CDN it also provides Web Security, because all the requests will be served by the Edge Server and if your CDN provides support to take care of DDOS attacks, CDN will block those requests


AkamaiGhost – Akamai Global Host – Geographically co-located Caching Server

AkamaiGhost – also known as Akamai Global Host – which is designed to serve as a “geographically co-located caching server” for a website. So, what they do is, they mirror the site on a server at different ISP/POPs to deliver the content faster from a closer location.

No comments:

Post a Comment