Dynamic Rendering ~ A BOON!!!

Dynamic Rendering ~ A BOON!!!

The SEO Score: -

SEO has potential to make a major impact on company’s most important goals, like sales & leads. Let start our conversation by understand a general trend. Whenever you search anything on google, you get list of websites on your respective browser. Generally, 90% of people open only those sites which are listed on 1st page & in very rare cases, most probably only 1-2% people, tends to open website listed on 2nd or max to max 3rd page. So, if we started an e-commerce website or online business either product based or content-based & woefully our website got listed on 4th page or 10th page then our business will be impacted.

So now very next and obvious question which arise is what’s the difference between sites those got listed on 1st page and those which got listed on 4th page???

A very simple answer is SEO score. SEO stands for “Search Engine Optimisation” & SEO score indicates how well your site perform which contributes to your website’s organic ranking. So, now what we need to know is what all factor impacts SEO score?

No alt text provided for this image

Well, there are many, and that’s the reason it is difficult to cover all the factors in one single article. Here, we would be considering one of the important factors and that is JavaScript execution time. JavaScript is one of the most important part of the web application which assist in making robust applications. Currently its difficult to process JavaScript & not all search engine crawlers are able to process it successfully or immediately. And this eventually results to a bad SEO score.

Thus, solution to this is “Dynamic Rendering”. Dynamic rendering is good for content that uses JavaScript feature that aren’t supported by the crawlers. Let’s understand the concept if dynamic rendering & then we will be proceeding to a very insightful DEMO.

The Concept of Dynamic Rendering: -

No alt text provided for this image


Dynamic Rendering is the process or concept in which we identify requests that are made by crawlers to our content & serve those requests with the content suitable to the crawler like a static HTML version of content etc. So, I guess it very clear what is needed to be done. Now, “HOW we can achieve this??”, I would like to answer this question with a DEMO.

The DEMO: -

In our current setup I am having a ALB(Application Load Balancer) in front of an ec2 instance. In the ec2 instance I am have 2 scripts namely crawl.html & bot.html. And I am serving this website with help of AWS CloudFront.

First let me show you what both the script contains.

  • crawl.html

No alt text provided for this image

  • bot.html

No alt text provided for this image

Now here, I have not created an entire web application because my moto is to just show how with help of Lambda edge function, we can implement the concept of dynamic rendering. In this scenario, I am assuming that crawlers would be crawling crawl.html page. Now as per dynamic rendering we need to identify the request made by crawler and serve bot.html page to crawler as response. Thus, whenever normal user would be hitting crawl.html page he/she would be getting “Hello normal users :)” as output but, when crawler would be hitting crawl.html page it would be getting “Hello Search Engine BOT!!!” as output. Seems quite interesting. Let run through the lambda edge function further. Below I have shown the Lambda edge function which I have used.


No alt text provided for this image


NOTE: - This Lambda function is viewer request Lambda function. Thus, we need to attach it on viewer request end. It will process/analyse the request before it hits to cloudfront.?



def lambda_handler(event, context):

??? request = event['Records'][0]['cf']['request']

??? headers = request['headers']

??? print(request)

???

??? useragent = request['headers']['user-agent'][0]['value']

??? if "Googlebot" in useragent:

????? print("Google Bot")

????? request["uri"] = "/bot.html"

????? print(request)

??? return request?        

?For identifying whether request to our page is made by “Googlebot” or a “regular user”, we can use ‘user-agent’ header. If request is been made by regular user, then value of user-agent header would be something like this

'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'

And if request is been made by Googlebot then value of user-agent would be like

'Mozilla/5.0 (compatible; Googlebot/2.1; +https://www.google.com/bot.html)'

So, in python function I have just simply used an if statement for identifying whether request has been made by regular user or Googlebot and accordingly I have changed uri for that respective request. This was the solution which I used, because I have not created a full fledge web application, thus I used this trick to demonstrate dynamic rendering. In real world what actually we can do is, we can pass custom header to our application or pass a specific query string to our application, whenever we identify that request has been initiated by Googlebot. And at backend our application will serve the content accordingly.

In the demo, first I made request to CloudFront as a regular user, and then I made a change in my chrome browser setting to stimulate the next request as if it was made by Googlebot.

Let’s view the demo :)?

No alt text provided for this image


I hope this article was useful for you. Don’t forget to share your feedback in comments?? Happy Learning & Happy Exploring!!!

Jaya Shukla

Public Speaking Expert at PlanetSpark || FINALIST UNESCO HACKATHON || SIH WINNER 2022 || Aspiring Software Engineer ||Youtuber|| Instagrammer|| ARTH2.0 Learner|| Expertized communication skills

2 年

Grt

MD MOQADDAS

DevOps & CloudOps Engineer ? Committed to System Reliability & Cloud Agility ? Team-Centric & Results-Driven

2 年

great

要查看或添加评论,请登录

Ayush Ganatra的更多文章

  • Privilege Escalation: Lets know the Hidden Danger.

    Privilege Escalation: Lets know the Hidden Danger.

    Introduction: Containers have revolutionized the way we build, ship, and run applications. They provide a lightweight…

  • Authentication ~ A custom Usecase & a different approch

    Authentication ~ A custom Usecase & a different approch

    hase 1 :The Usecase Hey folks, Recently I came across a very unique & interesting AWS architectural usecase & trust me…

    4 条评论
  • OpenSCAP ~ Let me check

    OpenSCAP ~ Let me check

    “Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young.

    4 条评论
  • What’s inside the Pod??

    What’s inside the Pod??

    Container has brought the revolutions in technical area. Seriously one of the most stunning yet simplest technology…

    12 条评论
  • Kafka Message Queue in a Nutshell

    Kafka Message Queue in a Nutshell

    In this blog we will see: What is Kafka ? Kafka as Message Queue Installation Demo(with cli & python script) Industry…

    2 条评论
  • GAN(Advance DL concept)

    GAN(Advance DL concept)

    In this blog I will explain GAN(one of the advance DL/ML concept) & it’s code from scratch with an example. In single…

    10 条评论
  • Image segmentation based on K-means algorithm

    Image segmentation based on K-means algorithm

    What is K-Means ?? Kmeans algorithm is an iterative algorithm that tries to partition the dataset into Kpre-defined…

  • OSPF Protocol implementing Dijkstra’s Algorithm

    OSPF Protocol implementing Dijkstra’s Algorithm

    Router works on third layer of our OSI model. OSPF (Open Shortest Path First) is a routing protocol.

    2 条评论
  • USE-CASE OF JavaScript

    USE-CASE OF JavaScript

    Walmart Strives to be an Online Retail Leader with Node.js Walmart needed to improve its business.

    6 条评论
  • Confusion matrix in Cyber crime

    Confusion matrix in Cyber crime

    Task Description ?? ?? Cyber crime cases where they talk about confusion matrix or its two types of error. WHAT IS…

    4 条评论

社区洞察

其他会员也浏览了