Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  1. Code
  2. Performance

How to Optimize and Accelerate Your Website With Imperva Incapsula

This post is part of a series called Securing Your Website with Incapsula.
Protecting Your AWS Website From a DDoS Attack
Sponsored Content

This sponsored post features a product relevant to our readers while meeting our editorial guidelines for being objective and educational.

Final product image
What You'll Be Creating

Introduction to Our Imperva Incapsula Series

This is the third of a series of sponsored tutorials covering Incapsula Website Security and performance services. In this tutorial, I'll introduce you to Incapsula CDN & Optimizer, showing you how easy it is to increase the speed of your website with its services.

If you'd like to start at the beginning of the series, read part one which provides an introduction to Incapsula Website Security and part two, which reviews Incapsula DDoS Protection with special attention to applications hosted by Amazon Web Services. 

If you're ready, you can visit the Incapsula website and learn more about the plans and pricing options as you read through our tutorial series. If you're not quite ready to sign up, Incapsula offers a complete demonstration site which you can browse. The demo site is a copy of an actual Incapsula account showing all of its services and functionality, but does not allow you to actually use the interface. If you have more detailed questions already, check out the Incapsula FAQs and Knowledge Base.

Please let me know if you have any requests for future episodes in this series or questions and comments on this tutorial. Either post them below as comments or reach me on Twitter @reifman or email me directly. 

Incapsula Optimization Features

With just a few minutes of simple integration steps, Incapsula provides a broad array of performance enhancements to your website. Here are some of the ways Incapsula speeds up your website:

  • A network of globally distributed data centers ensures that content is always delivered from a data center close to your users.
  • Application-aware Content Delivery Network (CDN) for what they call "Full Site Acceleration," also known as static and dynamic content caching (free for all account levels).
  • Dynamic profiling and frequency analysis ensure that your most frequently accessed resources are served directly from physical memory, completely bypassing the file system.
  • Maximizing cacheable content with the application-aware traffic analysis technologies which were developed for Incapsula Website Security.
  • Sophisticated content and networking optimization which minimizes latency.

The average Incapsula supported website is 50% faster and consumes 40–70% less bandwidth.

You may remember from part one that the Incapsula network's free subscription level provides a content delivery network for you. And, if you use the Pro account (available for free with a 14-day trial), there are additional performance optimizations. The Enterprise account provides more sophisticated load balancing features as well.

Incapsulacom Plan Options and Pricing

The Incapsula Content Delivery Network

Incapsula offers a Global CDN to all of its accounts. Its servers are located around the world to optimize content delivery to your site visitors:

Incapsulas Global Network Map

The Incapsula application-aware CDN dynamically profiles your website resources and identifies all cacheable content (dynamic and static)—including content that other CDNs are unable to cache. Its dynamic profiling and frequency analysis ensure that the most frequently accessed resources are identified and fetched directly from memory, speeding up content delivery by bypassing the file system. 

Here are a few more performance-enhancing features offered to free accounts (we'll review all of these in more detail below):

  • Static file compression
  • Content minification
  • On-the-fly image optimization
  • Async validation
  • Custom cache headers

Its Pro level plans offer these Advanced Performance features:

  • Advanced dynamic content caching
  • Dynamic content compression
  • Purging your cache
  • Force additional static resources
  • Pre-pooling
  • Progressive image rendering
  • Image compression

Finally, the Incapsula solution's Enterprise-level plans offer sophisticated Load Balancing capability as well:

Exploring Incapsula Optimization Features

Now, let's walk through the Incapsula administrative interface so you can see how these optimization features are observed and managed. You may remember the Dashboard from part one of our series. It provides you a summary of activity and security issues with your site:

Incapsula Dashboard

For this tutorial, I chose my Lookahead Consulting website. It's a fairly simple WordPress website which I currently host at Digital Ocean and optimize with Varnish and W3 Total Cache; I've written about this in earlier tutorials. I integrated the Incapsula solution in just a few minutes and gain all the additional benefits of their security and performance features. Incapsula is a fantastic enhancement to run fast, secure, scalable hosting off any low-cost hosting provider's basic plan. 

Incapsula Performance Features

Click on the Performance navigation to review the benefits of Incapula's optimizations on your website. You can see the percentage of bandwidth that's cached and how much bandwidth you've saved:

Incapsula Performance Dashboard

To manage these features, click on the Settings button and then the Performance icon on the left sidebar:

Incapsula Performance Settings

Content Caching

Incapsula provides four caching modes:

  1. Static Content Caching: This can cache your static content, such as HTML files, images or JavaScript resources and allows them to be served directly from the Incapsula network's globally distributed data centers. It also takes the load off your servers for these resources.
  2. Dynamic Content Caching: The Incapsula solution's patent-pending advanced learning continuously profiles website resources, gathering intelligence on each resource. Some of these resources, of course, are dynamically generated, rarely changing over time and for different users. This intelligence allows for optimized caching and ensures resource accuracy. Dynamic caching is only available with paid plans.
  3. Serving Pages from Memory: The Incapsula advanced learning and frequency analysis offer the added benefit of identifying the most frequently accessed resources, and serving them directly from physical memory, completely bypassing the file system and other generic mechanisms (such as buffer-cache). This speeds the experience for your customers more than other caching systems might provide.
  4. Client-Side Caching: Incapsula optimizes client-side caching by making sure that as much content as possible is cached on the visitor's browser or mobile device. Client-side caching ensures instant loading of resources and the best possible user experience. Based on the same advanced algorithms used for dynamic caching, Incapsula enriches browser caching instructions while setting the right refresh policy, so content always stays fresh—other browser caching products often fail because of their limitations, leaving users with stale content.

You can read about these caching modes in more detail at the Incapsula Global CDN & Caching page and its Caching Support page.

Your account level will control which caching modes you have available:

Incapsula Caching Settings

As you scroll down the page, you'll see more advanced Content Optimization settings available:

Incapsula Content Optimization

Minification: This is the process of removing all unnecessary characters from source code, without changing its functionality. In JavaScript, CSS and HTML code, these unnecessary characters usually include white spaces, new line characters and comments, often used to add readability to the code but not required for its execution. Incapsula removes these characters, minimizing web page size and weight, and reducing load time.

Image Compression: You can choose the types of image files you want to compress (JPG, PNG). Using aggressive compression for JPG files maximizes performance but may have a minor effect on picture quality. Alternatively, lossless JPG compression keeps the image itself intact, while stripping the metadata embedded in the image. Progressive image rendering allows pages to load more quickly while rendering multiple images in parallel.

"On the Fly" Compression: Common web servers and browsers support content compression; however, configuring server resource compression requires technical expertise and consumes valuable web server processing power. Incapsula dynamically compresses HTML, CSS and JavaScript files stored on its servers "on the fly" using GZIP (and HTTP/1.1 chunked transfer encoding where possible) to accelerate page load times. By compressing your website resources, Incapsula reduces the amount of data sent over the network without the hassle of server configuration.

You can read more about these settings in the Incapsula Content and Networking Optimization summary.

Finally, there are a variety of Advanced Settings available to customize as well:

Incapsula Caching Advanced Settings

You can add Advanced Caching Rules to customize caching as shown in the example below:

Incapsula Advanced Caching Rules

If you'd like a specific page or set of pages to be cached, it's easy to define a URL matching pattern for them. Similarly, you can exclude pages with the same kinds of patterns.

Purging Your Cache: Whenever you need to, you can purge your entire cache or a specific URL as shown below:

Incapsula Purge Cache Example

Using the Incapsula API for Caching Control

Incapsula provides an API that enables you to control caching policies in an efficient and automated manner. The API can be used to change caching modes, create custom caching rules, purge the cache, purge a specific resource or configure content optimization settings. The API enables easy integration and is particularly useful for companies managing large numbers of product or country-specific sites.

In Summary

Now that you've covered the series to see all of Incapsula's offering, why not take a look at what Incapsula can do for you?

Incapsula T-Shirt

I hope you've enjoyed this tutorial series enough to give Incapsula a try. I've written a number of sponsored tutorials for Tuts+ but I was uniquely impressed with the ease of integration that Incapsula provides while offering an affordable yet rich set of vital services. 

When you sign up for Incapsula, your website traffic is seamlessly routed through its globally distributed network of powerful servers. Your inbound traffic is intelligently profiled in real time, blocking the latest web threats (e.g., SQL injection attacks, scrapers, malicious bots, comment spammers), and with higher-level plans, thwarting DDoS attacks. Meanwhile your outbound traffic is sped up with the Incapsula network's global CDN. A lot of these features are provided for free, and you can try all of it without cost during their 14-day trials.

Incapsula is an impressive service that developers, consultants and publishers should know about.

As always, please feel free to post your questions and comments below. You can also reach me on Twitter @reifman or email me directly. Please check out my Tuts+ instructor page to read my other tutorials.

Related Links

Looking for something to help kick start your next project?
Envato Market has a range of items for sale to help get you started.