Code Monkey home page Code Monkey logo

sticky-cdn's Introduction

Sticky CDN - Content Delivery Network For Local Development

by Ben Nadel (on Google+)

This is small ColdFusion application that acts as a Content Delivery Network (CDN) for a local development environment. It's a simple pass-through cache layer that maps incoming requests to origin-server requests. It caches the given object and starts serving it up on subsequent requests without going back to the origin server.

Configuring Content Delivery Network

In order to get this local CDN application to work, you have to set up the virtual host in Apache and then set up the mappings for the request translation.

Apache Virtual Host

The Apache Virtual Host sets up the sever names as well as the URL rewrite rules. Every request that comes into Sticky CDN gets rewritten to run through the main index.cfm file.

<VirtualHost *:80>

	ServerName local.cdn.stickycdn.com
	ServerAlias local.cdn2.stickycdn.com
	ServerAlias local.cdn3.stickycdn.com

	ErrorLog /Path/To/Your/Sites/sticky_cdn/site/logs/error.log
	RewriteLog /Path/To/Your/Sites/sticky_cdn/site/logs/rewrite.log
	# RewriteLogLevel 7

	DocumentRoot "/Path/To/Your/Sites/sticky_cdn/site/wwwroot"
	
	<Directory "/Path/To/Your/Sites/sticky_cdn/site/wwwroot">

		Options Indexes FollowSymLinks
		AllowOverride All
		Order allow,deny
		Allow from all

		# ------------------------------------------------------------ #
		# ------------------------------------------------------------ #

		# Enable URL rewriting.

		RewriteEngine On

		# ------------------------------------------------------------ #
		# ------------------------------------------------------------ #

		# Rewrite all requests to the main index.cfm page (except for the index page).

		RewriteCond  %{REQUEST_URI}  !^/?index.cfm  [NC]
		RewriteRule  /?(.+)  index.cfm/$1  [L,QSA]

	</Directory>

</VirtualHost>

Obviously, you need to use paths that make sense for your computer.

Configuration

Once you have your virtual host set up, you can set up your config.json file that lives in site folder of the repository. At the very least, this configuration file has to have a collection of origin server mappings:

{
	"origin": {
		"local.cdn.stickycdn.com": "local.stickycdn.com"
	}
}

That's about it.

sticky-cdn's People

Contributors

bennadel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.