Source

appengine-cdn / mcdn / templates / mcdn / index.html

Full commit
{% extends 'base.html' %}

{% block title %}Instant CDN on Google App Engine{% endblock title %}

{% block content_title %}<h1>Instant CDN on Google App Engine</h1>{% endblock content_title %}

{% block content %}
<p>This is <a href="http://cdn-cloud.appspot.com/">Instant CDN on Google App Engine</a> clone built on <a href="http://flask.pocoo.org/">Flask</a> with some tweaks and additions. You can contact me at <a href="http://loutontheweb.co.cc/profile">profile page</a>.</p>

<h2>Features</h2>

<p>This web service will retrieve the resource located on your server, cache it on Google App Engine servers and serve it to your users with smart cache headers. This will provide the following benefits:</p>

<ul>
<li>Instant scalability for all of your static resources.</li>
<li>Faster page load of Web objects to the end user.</li>
<li>Reduces bandwidth needs and cost.</li>
<li>Reduces load on your web server.</li>
</ul>

<h2>Basic usage: file cache</h2>

<p>Replace all your files urls with:</p>

<pre><code>
http://{{ request.environ.HTTP_HOST }}/<strong>c</strong>/<strong>[unique_path]</strong>?url=<strong>[file_url]</strong>
</code></pre>

<p>For example, to cache an image at <a href="http://www.google.com/intl/en_ALL/images/logo.gif">http://www.google.com/intl/en_ALL/images/logo.gif</a>, use this url:</p>

<pre><code>
http://{{ request.environ.HTTP_HOST }}/c/google/logo.gif?url=http://www.google.com/intl/en_ALL/images/logo.gif
</code></pre>

<h2>Image Size</h2>

<p>To resize your image, specify a size parameter, i.e:</p>

<pre><code>
http://{{ request.environ.HTTP_HOST }}/c/google/logo.small.gif?url=http://www.google.com/intl/en_ALL/images/logo.gif&size=100x100
</code></pre>

<p>Valid values for size parameter:</p>

<ul>
<li>100x100 - resize to this dimension, retaining the original aspect ratio.</li>
<li>100x100b - resize to this dimension, only if the original is bigger.</li>
<li>100x100c - crop to this dimension.</li>
</ul>

<p>Size can also be specified in file name, i.e. <strong>logo.small__100x100c.gif</strong> (note double underscore).</p>

<h2>Subdomain</h2>

<p>You can use subdomains to avoid collisions with already existed file, i.e.:</p>

<pre><code>
http://[subdomain].{{ request.environ.HTTP_HOST }}/c/google/logo.small.gif?url=http://www.google.com/intl/en_ALL/images/logo.gif&size=100x100
</code></pre>

<pre><code>

</code></pre>

<h2>API</h2>

<h3>Adding file</h3>

<pre><code>
http://{{ request.environ.HTTP_HOST }}/<strong>a</strong>/<strong>[unique_path]</strong>?url=<strong>[url]</strong>&size=<strong>[image_size]</strong>
</code></pre>

<p>Response:</p>

<ul>
<li>Redirect to the file on server, i.e. http://{{ request.environ.HTTP_HOST }}/<strong>s</strong>/<strong>[unique_path]</strong></li>
<li>404 page if provided [url] can't be fetched.</li>
<li>500 page if provided [size] is in unknown format or file at [url] is not image.</li>
</ul>

<h3>Serving file</h3>

<pre><code>
http://{{ request.environ.HTTP_HOST }}/<strong>s</strong>/<strong>[unique_path]</strong>
</code></pre>

<p>Response:</p>

<ul>
<li>200 page with requested file.</li>
<li>404 page if requested file not found.</li>
</ul>

<h3>Caching file</h3>

This is combination of adding and serving file in one step. If file at [unique_path] exists on server (i.e. is already cached) it will be served. Otherwise file will be fetched from the [url] and cached on the server, then cached file will be served.

<pre><code>
http://{{ request.environ.HTTP_HOST }}/<strong>c</strong>/<strong>[unique_path]</strong>?url=<strong>[url]</strong>&size=<strong>[image_size]</strong>
</code></pre>

<p>Response:</p>

<ul>
<li>200 page with requested file.</li>
<li>404 page if provided [url] can't be fetched.</li>
</ul>

<p>
If size can't be recongized or file is not image nothing happens.
</p>
{% endblock content %}