Skip to content

SERA integration on CloudFront

Kindly follow the below steps to setup the routing of bot traffic to SERA.

Steps

  1. Creating a function

    1. Open Cloudfront Dashboard, and select Functions menu on the left side
      Step

    2. Click on Create function
      Step

    3. Fill the details as shown below :
      Name:

      n7-sera-routing
      
      In Runtime, select Cloudfront-js-2.0
      And then Click on Create function
      Step

    4. Select Build tab
      Copy the code from this js file, and paste it in the textarea.
      Put the SERA token shared with you in SERA_TOKEN variable value
      Keep required value uncommented for BOTS variable based on testing/live phase
      Click on Save
      Step

    5. Select Test tab
      Leave everything unchanged, and click on Test function. You should then see a success message.
      Step

    6. Select Publish tab
      Click on Publish function
      Step

  2. Associating the function to Behavior

    1. Select Distributions menu on Left
      Step

    2. Click on the respective distribution from the list
      Select Behaviors tab
      Step

    3. Select respective behavior, and Edit it
      Step

    4. Go to bottom Function associations section at bottom
      Step

    5. In Viewer request section, select Cloudfront Functions as Function type
      Step

    6. Select the created function (n7-sera-routing) in Function ARN/Name dropdown
      Step

    7. Save

  3. Testing and Refinement

    • Keep refining the logic by adjusting user-agent list, and SERA exclusion-patterns as needed.
    • Test thoroughly:
      • WPT and GTMetrix will automatically receive the response from SERA due to the routing rule set above.
        • Steps to validate page using WPT
      • To check the SERA rendered page on browser, you can use some browser extension (like Simple modify headers) to manipulate the browser user-agent.
        If in testing phase, use these user-agent values:
        For desktop:
        n7TestUserAgent
        
        For mobile:
        n7TestUserAgent; Android
        
        If SERA is live, you can use these actual bot user-agent values:
        For desktop:
        Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Googlebot/2.1; +<http://www.google.com/bot.html)> Chrome/W.X.Y.Z Safari/537.36
        
        For mobile:
        Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/W.X.Y.Z Mobile Safari/537.36 (compatible; Googlebot/2.1; +<http://www.google.com/bot.html)>
        
    • On go-live day, set the user-agent condition regex to actual bot user-agent values. Additionally, ensure that your condition is case-insensitive.