customer's business through a partnership focused on expertise, innovation, and education. [email protected] Javier Garza Senior Enterprise Architect Santa Clara, CA, USA [email protected] https://www.linkedin.com/in/jjgarza
ESI • How the Akamai implementation differs from other ESI implementation • Examples of things you can achieve using ESI • Debugging ESI code: o ESI Web debugging tool in Luna o ESI environment with built-in debugger o ETS Server o ETS Docker image
ESI (Edge Side Includes) is a small markup language for dynamic web content assembly at the Edge. Fills the gap between SSI (server) and AJAX (client) • ESI was proposed as a standard in 2001, but was not accepted by the W3C. • ESI implementations exist on a few proxy servers like Varnish, Squid and Mongrel. The Akamai implementation extended considerably the ESI 1.0 standard • Official Akamai page: https://www.akamai.com/us/en/support/esi.jsp <html> … <esi:include src=”http://3rdparty.com/ad.html"/> … </html>
language • Ability to indicate cache settings per include • Asynchronous includes and the ability to indicate a max time to wait for a given include • stylesheet (an XSL stylesheet for XSLT) • Support for alternate methods (like POST) • Ability to dynamically add, edit or remove HTTP headers • esi:eval (include objects and evaluate the ESI fragment’s in the parent namespace) • foreach loops (iterations) • Internationalization • Functions (string manipulation, conversion, random, custom functions) • Variables, expressions, cookie support, boolean operators, etc.
• Allow caching the home page while customizing it for returning users <esi:choose> <esi:when test="$exists($(HTTP_COOKIE{'User'}))"> <esi:include src=”/profile/$(HTTP_COOKIE{'User'})" onerror="continue" maxwait="0" dca=“esi” no-store=“on”/> </esi:when> </esi:choose> <esi:include src=”/index_$(GEO{'country_code'}).html" alt="index_generic.html" ttl="2h" onerror="continue" maxwait=”2000"/> • Load country-specific settings (if they exist) • Load the news of the current day (if they exist) <esi:comment text=": load today’s news. For example: /news/2017/10/16/index.html"/> <esi:include src="/news/$strftime($time(), '%Y/%m/%d')/index.html" alt="/news/index.html"/>
•Track first time users, and greet returning users <esi:choose> <esi:when test=“$(HTTP_COOKIE{'returning_visitor'})”> Hi there, hello again! </esi:when> <esi:otherwise> Do I know you? $add_header('Set-Cookie','returning_visitor=1; expires='+$http_time($time()+36000)+';') </esi:otherwise> </esi:choose> <esi:choose> <esi:when test=”$(HTTP_COOKIE{’returning_visitor'}) && $rand(100) > 50"> <esi:include src=”/newcode.html" no-store=”on" onerror="continue" maxwait=”0"/> </esi:when> </esi:choose> • Test new code with 50% of returning users
Development tool (1 of 3) Allows to run Akamai’s internal ESI debugger on an external URL: https://control.akamai.com/portal/esid_2.jsp (Short URL: https://goo.gl/ZAFVyF) Requirements: •URL must be delivered over Akamai •Allow pop-ups from control.akamai.com •Your Akamai contract needs to have the required ESI line item
production Dev environment Requires a little effort to setup, but it is probably the best option if you have to debug ESI often. Create a dedicated hostname for ESI debugging (for example esi- debug.example.com), and enable the built-in ESI debugger via debug tag by adding the following line of advanced MD* to the Akamai configuration: <edgecomputing:esi.debug.enable-debug-tag>on</edgecomputing:esi.debug.enable-debug- tag> Insert the <esi:debug/> tag within the Web page containing the ESI code you want to debug. Open the page with a Web browser, right-click and select “View Source” to see the ESI debugging output *Note: Adding advanced Metadata requires Akamai Professional Services
is a reverse proxy built with Apache and mod_esi that can be used to test ESI-enabled content. Official images you can download from www.akamai.com: • ETS for Linux version 5.3.1.0 compiled with GCC 3.3.4 on Fedora Core 3 • ETS for Linux version 5.3.1.0 compiled with GCC 4.1.2 on Fedora Core 7 Un-official latest image (download upon request): • ETS for Linux 6.0.0.4 on Ubuntu (use ETS Docker image)
Dockerhub since July 2017. Install Docker and run the command below in a Terminal window: sudo docker run -ti -p 8080:80 akamaiesi/ets-docker:latest --debug localhost Open a Web browser and navigate to http://localhost:8080/playground Note: ETS Docker is useful for debugging basic functionality (lacks Edge server environment)