CDP:URL Rewriting pattern

From AWS-CloudDesignPattern
Revision as of 00:34, 15 November 2012 by Cdpadmin (Talk | contribs)
Jump to: navigation, search

Saving Static Content


Problem to Be Solved

When a web service is provided by a virtual server, if the number of accesses becomes too large, the load is handled by increasing the number of virtual servers or upgrading the specifications of the virtual servers. However, often the majority of the accesses are requests for static content, so how to distribute access to static content has become an important issue.

Explanation of the Cloud Solution/Pattern

The use of Internet storage is a way to distribute access of static content. This makes it possible to handle the load without increasing the number of virtual servers.

The use of this method requires that the URL for the static content be changed to a URL for the Internet storage, but along with a method of directly adjusting the static content, it is also possible to change the URL, at the time of delivery, using the Filter function of the web server. Moreover, instead of delivering from Internet storage, it is also possible to deliver the content from a content delivery server.


In AWS, Amazon Simple Storage Service (S3) can be used in delivery of static content. Using content located on Amazon Simple Storage Service (S3) as the original, and using the CloudFront content delivery service makes it possible to deliver content globally without delay.


  • Upload (synchronize) a portion of the static content (JavaScript/CSS/images, etc.) of the EC2 to S3.
  • If necessary, generate a CloudFront using, as the original, the S3 wherein the static content has been uploaded (synchronized). (When CloudFront is used, it is also possible to use an EC2 instance directly as the original server, rather than S3.)
  • Overwrite the static content URLs in the HTML tags with those of the S3 or of CloudFront.
  • It is possible to use the Apache filter module (mod_ext_filter<ref group="Related Blog"> Template:Related Blog </ref>/mod_sed<ref group="Related Blog"> Template:Related Blog </ref>)or Nginx, prepared as a proxy, to perform the overwriting dynamically.




  • Distribution of access of static content to S3/CloudFront can provide greater robustness to load and can also reduce EC2 costs.
  • The use of CloudFront is also a way to handle latency caused by distance in worldwide delivery.
  • When mod_ext_filter/mod_sed, Nginx, or the like is used, this pattern can be applied through the insertion of a filter, without modifying the original HTML file. Moreover, it is easy to fall back to the state wherein CloudFront is not used, by simply turning the filter off.


  • When CloudFront is used, there may be some cases wherein deletion or updating may be delayed due to content caching.


Related Blog

<references group="Related Blog"/>

Personal tools