diff --git a/django/contrib/admin/templates/admin/auth/user/change_password.html b/django/contrib/admin/templates/admin/auth/user/change_password.html
index c280f50..b18b0aa 100644
--- a/django/contrib/admin/templates/admin/auth/user/change_password.html
+++ b/django/contrib/admin/templates/admin/auth/user/change_password.html
@@ -1,5 +1,5 @@
 {% extends "admin/base_site.html" %}
-{% load i18n static admin_modify %}
+{% load i18n admin_static admin_modify %}
 {% load url from future %}
 {% block extrahead %}{{ block.super }}
 {% url 'admin:jsi18n' as jsi18nurl %}
diff --git a/django/contrib/admin/templates/admin/base.html b/django/contrib/admin/templates/admin/base.html
index 9282440..4b3c429 100644
--- a/django/contrib/admin/templates/admin/base.html
+++ b/django/contrib/admin/templates/admin/base.html
@@ -1,4 +1,4 @@
-{% load static %}{% load url from future %}<!DOCTYPE html>
+{% load admin_static %}{% load url from future %}<!DOCTYPE html>
 <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
 <head>
 <title>{% block title %}{% endblock %}</title>
diff --git a/django/contrib/admin/templates/admin/change_form.html b/django/contrib/admin/templates/admin/change_form.html
index c5e428d..56661e9 100644
--- a/django/contrib/admin/templates/admin/change_form.html
+++ b/django/contrib/admin/templates/admin/change_form.html
@@ -1,5 +1,5 @@
 {% extends "admin/base_site.html" %}
-{% load i18n static admin_modify %}
+{% load i18n admin_static admin_modify %}
 {% load url from future %}
 
 {% block extrahead %}{{ block.super }}
diff --git a/django/contrib/admin/templates/admin/change_list.html b/django/contrib/admin/templates/admin/change_list.html
index 29af47f..24c6d8c 100644
--- a/django/contrib/admin/templates/admin/change_list.html
+++ b/django/contrib/admin/templates/admin/change_list.html
@@ -1,5 +1,5 @@
 {% extends "admin/base_site.html" %}
-{% load i18n static admin_list %}
+{% load i18n admin_static admin_list %}
 {% load url from future %}
 {% block extrastyle %}
   {{ block.super }}
diff --git a/django/contrib/admin/templates/admin/change_list_results.html b/django/contrib/admin/templates/admin/change_list_results.html
index 233d4e1..b1db647 100644
--- a/django/contrib/admin/templates/admin/change_list_results.html
+++ b/django/contrib/admin/templates/admin/change_list_results.html
@@ -1,4 +1,4 @@
-{% load i18n static %}
+{% load i18n admin_static %}
 {% if result_hidden_fields %}
 <div class="hiddenfields">{# DIV for HTML validation #}
 {% for item in result_hidden_fields %}{{ item }}{% endfor %}
diff --git a/django/contrib/admin/templates/admin/edit_inline/stacked.html b/django/contrib/admin/templates/admin/edit_inline/stacked.html
index 7e69450..476e261 100644
--- a/django/contrib/admin/templates/admin/edit_inline/stacked.html
+++ b/django/contrib/admin/templates/admin/edit_inline/stacked.html
@@ -1,4 +1,4 @@
-{% load i18n static %}
+{% load i18n admin_static %}
 <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
   <h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
 {{ inline_admin_formset.formset.management_form }}
diff --git a/django/contrib/admin/templates/admin/edit_inline/tabular.html b/django/contrib/admin/templates/admin/edit_inline/tabular.html
index 8294227..29db95a 100644
--- a/django/contrib/admin/templates/admin/edit_inline/tabular.html
+++ b/django/contrib/admin/templates/admin/edit_inline/tabular.html
@@ -1,4 +1,4 @@
-{% load i18n static admin_modify %}
+{% load i18n admin_static admin_modify %}
 <div class="inline-group" id="{{ inline_admin_formset.formset.prefix }}-group">
   <div class="tabular inline-related {% if forloop.last %}last-related{% endif %}">
 {{ inline_admin_formset.formset.management_form }}
diff --git a/django/contrib/admin/templates/admin/index.html b/django/contrib/admin/templates/admin/index.html
index 0f81a1a..7164220 100644
--- a/django/contrib/admin/templates/admin/index.html
+++ b/django/contrib/admin/templates/admin/index.html
@@ -1,5 +1,5 @@
 {% extends "admin/base_site.html" %}
-{% load i18n static %}
+{% load i18n admin_static %}
 
 {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/dashboard.css" %}" />{% endblock %}
 
diff --git a/django/contrib/admin/templates/admin/login.html b/django/contrib/admin/templates/admin/login.html
index a95cfd8..dbaa119 100644
--- a/django/contrib/admin/templates/admin/login.html
+++ b/django/contrib/admin/templates/admin/login.html
@@ -1,5 +1,5 @@
 {% extends "admin/base_site.html" %}
-{% load i18n static %}
+{% load i18n admin_static %}
 
 {% block extrastyle %}{{ block.super }}<link rel="stylesheet" type="text/css" href="{% static "admin/css/login.css" %}" />{% endblock %}
 
diff --git a/django/contrib/admin/templates/admin/search_form.html b/django/contrib/admin/templates/admin/search_form.html
index 2b23a21..162b54a 100644
--- a/django/contrib/admin/templates/admin/search_form.html
+++ b/django/contrib/admin/templates/admin/search_form.html
@@ -1,4 +1,4 @@
-{% load i18n static %}
+{% load i18n admin_static %}
 {% if cl.search_fields %}
 <div id="toolbar"><form id="changelist-search" action="" method="get">
 <div><!-- DIV needed for valid HTML -->
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index 7a3a9b8..0f5eafc 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -3,9 +3,9 @@ import datetime
 from django.contrib.admin.util import lookup_field, display_for_field, label_for_field
 from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE,
     ORDER_VAR, PAGE_VAR, SEARCH_VAR)
+from django.contrib.admin.templatetags.admin_static import static
 from django.core.exceptions import ObjectDoesNotExist
 from django.db import models
-from django.templatetags.static import static
 from django.utils import formats
 from django.utils.html import escape, conditional_escape
 from django.utils.safestring import mark_safe
diff --git a/django/contrib/admin/templatetags/admin_static.py b/django/contrib/admin/templatetags/admin_static.py
new file mode 100644
index 0000000..5ea3ba5
--- /dev/null
+++ b/django/contrib/admin/templatetags/admin_static.py
@@ -0,0 +1,11 @@
+from django.conf import settings
+from django.template import Library
+
+register = Library()
+
+if 'django.contrib.staticfiles' in settings.INSTALLED_APPS:
+    from django.contrib.staticfiles.templatetags.staticfiles import static
+else:
+    from django.templatetags.static import static
+
+static = register.simple_tag(static)
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 038351e..d7dc1a5 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -7,12 +7,13 @@ from django import forms
 from django.core.urlresolvers import reverse
 from django.forms.widgets import RadioFieldRenderer
 from django.forms.util import flatatt
-from django.templatetags.static import static
 from django.utils.html import escape
 from django.utils.text import Truncator
 from django.utils.translation import ugettext as _
 from django.utils.safestring import mark_safe
 from django.utils.encoding import force_unicode
+from django.contrib.admin.templatetags.admin_static import static
+
 
 class FilteredSelectMultiple(forms.SelectMultiple):
     """
@@ -31,9 +32,11 @@ class FilteredSelectMultiple(forms.SelectMultiple):
         super(FilteredSelectMultiple, self).__init__(attrs, choices)
 
     def render(self, name, value, attrs=None, choices=()):
-        if attrs is None: attrs = {}
+        if attrs is None:
+            attrs = {}
         attrs['class'] = 'selectfilter'
-        if self.is_stacked: attrs['class'] += 'stacked'
+        if self.is_stacked:
+            attrs['class'] += 'stacked'
         output = [super(FilteredSelectMultiple, self).render(name, value, attrs, choices)]
         output.append(u'<script type="text/javascript">addEvent(window, "load", function(e) {')
         # TODO: "id_" is hard-coded here. This should instead use the correct
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index dd597ad..ead95ac 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -4,12 +4,11 @@ import os
 import sys
 from optparse import make_option
 
-from django.conf import settings
-from django.core.files.storage import FileSystemStorage, get_storage_class
+from django.core.files.storage import FileSystemStorage
 from django.core.management.base import CommandError, NoArgsCommand
 from django.utils.encoding import smart_str, smart_unicode
 
-from django.contrib.staticfiles import finders
+from django.contrib.staticfiles import finders, storage
 
 
 class Command(NoArgsCommand):
@@ -18,32 +17,36 @@ class Command(NoArgsCommand):
     locations to the settings.STATIC_ROOT.
     """
     option_list = NoArgsCommand.option_list + (
-        make_option('--noinput', action='store_false', dest='interactive',
-            default=True, help="Do NOT prompt the user for input of any kind."),
+        make_option('--noinput',
+            action='store_false', dest='interactive', default=True,
+            help="Do NOT prompt the user for input of any kind."),
         make_option('-i', '--ignore', action='append', default=[],
             dest='ignore_patterns', metavar='PATTERN',
             help="Ignore files or directories matching this glob-style "
                 "pattern. Use multiple times to ignore more."),
-        make_option('-n', '--dry-run', action='store_true', dest='dry_run',
-            default=False, help="Do everything except modify the filesystem."),
-        make_option('-c', '--clear', action='store_true', dest='clear',
-            default=False, help="Clear the existing files using the storage "
-                "before trying to copy or link the original file."),
-        make_option('-l', '--link', action='store_true', dest='link',
-            default=False, help="Create a symbolic link to each file instead of copying."),
+        make_option('-n', '--dry-run',
+            action='store_true', dest='dry_run', default=False,
+            help="Do everything except modify the filesystem."),
+        make_option('-c', '--clear',
+            action='store_true', dest='clear', default=False,
+            help="Clear the existing files using the storage "
+                 "before trying to copy or link the original file."),
+        make_option('-l', '--link',
+            action='store_true', dest='link', default=False,
+            help="Create a symbolic link to each file instead of copying."),
         make_option('--no-default-ignore', action='store_false',
             dest='use_default_ignore_patterns', default=True,
             help="Don't ignore the common private glob-style patterns 'CVS', "
                 "'.*' and '*~'."),
     )
-    help = "Collect static files from apps and other locations in a single location."
+    help = "Collect static files in a single location."
+    storage = storage.configured_storage
 
     def __init__(self, *args, **kwargs):
         super(NoArgsCommand, self).__init__(*args, **kwargs)
         self.copied_files = []
         self.symlinked_files = []
         self.unmodified_files = []
-        self.storage = get_storage_class(settings.STATICFILES_STORAGE)()
         try:
             self.storage.path('')
         except NotImplementedError:
@@ -104,7 +107,7 @@ Type 'yes' to continue, or 'no' to cancel: """
 
         handler = {
             True: self.link_file,
-            False: self.copy_file
+            False: self.copy_file,
         }[self.symlink]
 
         for finder in finders.get_finders():
@@ -116,7 +119,14 @@ Type 'yes' to continue, or 'no' to cancel: """
                     prefixed_path = path
                 handler(path, prefixed_path, storage)
 
-        actual_count = len(self.copied_files) + len(self.symlinked_files)
+        modified_files = self.copied_files + self.symlinked_files
+        actual_count = len(modified_files)
+
+        # Here we check if the storage backend has a post_process method
+        # and pass it the list of modified files, if possible.
+        if hasattr(self.storage, 'post_process'):
+            self.storage.post_process(modified_files)
+
         unmodified_count = len(self.unmodified_files)
         if self.verbosity >= 1:
             self.stdout.write(smart_str(u"\n%s static file%s %s %s%s.\n"
@@ -146,7 +156,8 @@ Type 'yes' to continue, or 'no' to cancel: """
         for f in files:
             fpath = os.path.join(path, f)
             if self.dry_run:
-                self.log(u"Pretending to delete '%s'" % smart_unicode(fpath), level=1)
+                self.log(u"Pretending to delete '%s'" %
+                         smart_unicode(fpath), level=1)
             else:
                 self.log(u"Deleting '%s'" % smart_unicode(fpath), level=1)
                 self.storage.delete(fpath)
@@ -159,7 +170,8 @@ Type 'yes' to continue, or 'no' to cancel: """
         if self.storage.exists(prefixed_path):
             try:
                 # When was the target file modified last time?
-                target_last_modified = self.storage.modified_time(prefixed_path)
+                target_last_modified = \
+                    self.storage.modified_time(prefixed_path)
             except (OSError, NotImplementedError):
                 # The storage doesn't support ``modified_time`` or failed
                 pass
@@ -177,8 +189,10 @@ Type 'yes' to continue, or 'no' to cancel: """
                         full_path = None
                     # Skip the file if the source file is younger
                     if target_last_modified >= source_last_modified:
-                        if not ((self.symlink and full_path and not os.path.islink(full_path)) or
-                                (not self.symlink and full_path and os.path.islink(full_path))):
+                        if not ((self.symlink and full_path
+                                 and not os.path.islink(full_path)) or
+                                (not self.symlink and full_path
+                                 and os.path.islink(full_path))):
                             if prefixed_path not in self.unmodified_files:
                                 self.unmodified_files.append(prefixed_path)
                             self.log(u"Skipping '%s' (not modified)" % path)
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index a69ae23..fdb8b3d 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -1,7 +1,15 @@
+import hashlib
 import os
+import posixpath
+import re
+
 from django.conf import settings
+from django.core.cache import (get_cache, InvalidCacheBackendError,
+                               cache as default_cache)
 from django.core.exceptions import ImproperlyConfigured
-from django.core.files.storage import FileSystemStorage
+from django.core.files.storage import FileSystemStorage, get_storage_class
+from django.utils.encoding import force_unicode
+from django.utils.functional import LazyObject
 from django.utils.importlib import import_module
 
 from django.contrib.staticfiles import utils
@@ -27,7 +35,131 @@ class StaticFilesStorage(FileSystemStorage):
             raise ImproperlyConfigured("You're using the staticfiles app "
                 "without having set the STATIC_URL setting.")
         utils.check_settings()
-        super(StaticFilesStorage, self).__init__(location, base_url, *args, **kwargs)
+        super(StaticFilesStorage, self).__init__(location, base_url,
+                                                 *args, **kwargs)
+
+
+class CachedFilesMixin(object):
+    cached_patterns = [
+        r"""(url\(['"]{0,1}\s*(.*?)["']{0,1}\))""",
+        r"""(@import\s*["']\s*(.*?)["'])""",
+    ]
+
+    def __init__(self, *args, **kwargs):
+        super(CachedFilesMixin, self).__init__(*args, **kwargs)
+        self.saved_files = []
+        try:
+            self.cache = get_cache('staticfiles')
+        except InvalidCacheBackendError:
+            # Use the default backend
+            self.cache = default_cache
+        self._cached_patterns = []
+        for pattern in self.cached_patterns:
+            self._cached_patterns.append(re.compile(pattern))
+
+    def hashed_name(self, name, content=None):
+        if content is None:
+            if not self.exists(name):
+                raise ValueError("The file '%s' could not be found using %r." %
+                                 (name, self))
+            try:
+                content = self.open(name)
+            except IOError, e:
+                # Handle directory paths
+                return name
+        path, filename = os.path.split(name)
+        root, ext = os.path.splitext(filename)
+        # Get the MD5 hash of the file
+        md5 = hashlib.md5()
+        for chunk in content.chunks():
+            md5.update(chunk)
+        md5sum = md5.hexdigest()[:12]
+        return os.path.join(path, u"%s.%s%s" % (root, md5sum, ext))
+
+    def cache_key(self, name):
+        return u'staticfiles:cache:%s' % name
+
+    def url(self, name, force=False):
+        """
+        Returns the real URL in DEBUG mode.
+        """
+        if settings.DEBUG and not force:
+            return super(CachedFilesMixin, self).url(name)
+        cache_key = self.cache_key(name)
+        hashed_name = self.cache.get(cache_key)
+        if hashed_name is None:
+            hashed_name = self.hashed_name(name)
+        return super(CachedFilesMixin, self).url(hashed_name)
+
+    def save(self, name, content):
+        original_name = super(CachedFilesMixin, self).save(name, content)
+
+        # Return the name if the file is already there
+        hashed_name = self.hashed_name(original_name, content)
+        if os.path.exists(hashed_name):
+            return hashed_name
+
+        # or save the file with the hashed name
+        saved_name = self._save(hashed_name, content)
+
+        # Use filenames with forward slashes, even on Windows
+        hashed_name = force_unicode(saved_name.replace('\\', '/'))
+        self.cache.set(self.cache_key(name), hashed_name)
+        self.saved_files.append((name, hashed_name))
+        return hashed_name
+
+    def url_converter(self, name):
+        """
+        Returns the custom URL converter for the given file name.
+        """
+        def converter(matchobj):
+            """
+            Converts the matched URL depending on the parent level (`..`)
+            and returns the normalized and hashed URL using the url method
+            of the storage.
+            """
+            matched, url = matchobj.groups()
+            # Completely ignore http(s) prefixed URLs
+            if url.startswith(('http', 'https')):
+                return matched
+            name_parts = name.split('/')
+            # Using posix normpath here to remove duplicates
+            result = url_parts = posixpath.normpath(url).split('/')
+            level = url.count('..')
+            if level:
+                result = name_parts[:-level-1] + url_parts[level:]
+            elif name_parts[:-1]:
+                result = name_parts[:-1] + url_parts[-1:]
+            joined_result = '/'.join(result)
+            hashed_url = self.url(joined_result, force=True)
+            # Return the hashed and normalized version to the file
+            return 'url("%s")' % hashed_url
+        return converter
+
+    def path_level(self, (name, hashed_name)):
+        return len(name.split('/'))
+
+    def post_process(self, paths):
+        """
+        Post process method called by the collectstatic management command.
+        """
+        self.cache.delete_many([self.cache_key(path) for path in paths])
+        for name, hashed_name in sorted(
+                self.saved_files, key=self.path_level, reverse=True):
+            with self.open(name) as original_file:
+                content = original_file.read()
+                for pattern in self._cached_patterns:
+                    content = pattern.sub(self.url_converter(name), content)
+            with open(self.path(hashed_name), 'w') as hashed_file:
+                hashed_file.write(content)
+
+
+class CachedStaticFilesStorage(CachedFilesMixin, StaticFilesStorage):
+    """
+    A static file system storage backend which also saves
+    hashed copies of the files it saves.
+    """
+    pass
 
 
 class AppStaticStorage(FileSystemStorage):
@@ -47,3 +179,10 @@ class AppStaticStorage(FileSystemStorage):
         mod_path = os.path.dirname(mod.__file__)
         location = os.path.join(mod_path, self.source_dir)
         super(AppStaticStorage, self).__init__(location, *args, **kwargs)
+
+
+class ConfiguredStorage(LazyObject):
+    def _setup(self):
+        self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
+
+configured_storage = ConfiguredStorage()
diff --git a/django/contrib/staticfiles/templatetags/__init__.py b/django/contrib/staticfiles/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/django/contrib/staticfiles/templatetags/staticfiles.py b/django/contrib/staticfiles/templatetags/staticfiles.py
new file mode 100644
index 0000000..80cf53e
--- /dev/null
+++ b/django/contrib/staticfiles/templatetags/staticfiles.py
@@ -0,0 +1,13 @@
+from django import template
+from django.contrib.staticfiles.storage import configured_storage
+
+register = template.Library()
+
+
+@register.simple_tag
+def static(path):
+    """
+    A template tag that returns the URL to a file
+    using staticfiles' storage backend
+    """
+    return configured_storage.url(path)
diff --git a/docs/howto/static-files.txt b/docs/howto/static-files.txt
index 16f8ac4..465b5ba 100644
--- a/docs/howto/static-files.txt
+++ b/docs/howto/static-files.txt
@@ -70,7 +70,7 @@ Basic usage
 
        <img src="{{ STATIC_URL }}images/hi.jpg" />
 
-   See :ref:`staticfiles-in-templates` for more details, including an
+   See :ref:`staticfiles-in-templates` for more details, **including** an
    alternate method using a template tag.
 
 Deploying static files in a nutshell
@@ -143,7 +143,7 @@ A far better way is to use the value of the :setting:`STATIC_URL` setting
 directly in your templates. This means that a switch of static files servers
 only requires changing that single value. Much better!
 
-``staticfiles`` includes two built-in ways of getting at this setting in your
+Django includes multiple built-in ways of using this setting in your
 templates: a context processor and a template tag.
 
 With a context processor
@@ -180,14 +180,19 @@ but in views written by hand you'll need to explicitly use ``RequestContext``
 To see how that works, and to read more details, check out
 :ref:`subclassing-context-requestcontext`.
 
+Another option is the :ttag:`get_static_prefix` template tag that is part of
+Django's core.
+
 With a template tag
 -------------------
 
-To easily link to static files Django ships with a :ttag:`static` template tag.
+The more powerful tool is the :ttag:`static<staticfiles-static>` template
+tag. It builds the URL for the given relative path by using the configured
+:setting:`STATICFILES_STORAGE` storage.
 
 .. code-block:: html+django
 
-    {% load static %}
+    {% load staticfiles %}
     <img src="{% static "images/hi.jpg" %}" />
 
 It is also able to consume standard context variables, e.g. assuming a
@@ -195,30 +200,21 @@ It is also able to consume standard context variables, e.g. assuming a
 
 .. code-block:: html+django
 
-    {% load static %}
+    {% load staticfiles %}
     <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen" />
 
-Another option is the :ttag:`get_static_prefix` template tag. You can use
-this if you're not using :class:`~django.template.RequestContext` (and
-therefore not relying on the ``django.core.context_processors.static``
-context processor), or if you need more control over exactly where and how
-:setting:`STATIC_URL` is injected into the template. Here's an example:
-
-.. code-block:: html+django
-
-    {% load static %}
-    <img src="{% get_static_prefix %}images/hi.jpg" />
-
-There's also a second form you can use to avoid extra processing if you need
-the value multiple times:
-
-.. code-block:: html+django
+.. note::
 
-    {% load static %}
-    {% get_static_prefix as STATIC_PREFIX %}
+    There is also a template tag named :ttag:`static` in Django's core set
+    of :ref:`built in template tags<ref-templates-builtins-tags>` which has
+    the same argument signature but only uses `urlparse.urljoin()`_ with the
+    :setting:`STATIC_URL` setting and the given path. This has the
+    disadvantage of not being able to easily switch the storage backend
+    without changing the templates, so in doubt use the ``staticfiles``
+    :ttag:`static<staticfiles-static>`
+    template tag.
 
-    <img src="{{ STATIC_PREFIX }}images/hi.jpg" />
-    <img src="{{ STATIC_PREFIX }}images/hi2.jpg" />
+.. _`urlparse.urljoin()`: http://docs.python.org/library/urlparse.html#urlparse.urljoin
 
 .. _staticfiles-development:
 
diff --git a/docs/ref/contrib/staticfiles.txt b/docs/ref/contrib/staticfiles.txt
index 5ab3c1e..abf8c58 100644
--- a/docs/ref/contrib/staticfiles.txt
+++ b/docs/ref/contrib/staticfiles.txt
@@ -237,7 +237,101 @@ Example usage::
 
     django-admin.py runserver --insecure
 
-.. currentmodule:: None
+Storages
+========
+
+StaticFilesStorage
+------------------
+
+.. class:: storage.StaticFilesStorage
+
+A subclass of the :class:`~django.core.files.storage.FileSystemStorage`
+storage backend that uses the :setting:`STATIC_ROOT` setting as the base
+file system location and the :setting:`STATIC_URL` setting respectively
+as the base URL.
+
+CachedStaticFilesStorage
+------------------------
+
+.. class:: storage.CachedStaticFilesStorage
+
+A subclass of the :class:`~django.contrib.staticfiles.storage.StaticFilesStorage`
+storage backend which caches the files it saves by appending the MD5 hash of
+the file's content to the filename. For example, the file ``css/styles.css``
+would also be saved as ``css/styles.55e7cbb9ba48.css``.
+
+The purpose of this storage is to keep serving the old files in case some
+pages still refer to those files, e.g. because they are cached by you or a
+3rd party proxy server. Additionally, it's very helpful if you want to apply
+`far future Expires headers`_ to the deployed files to speed up the load time
+for subsequent page visits.
+
+The storage backend automatically replaces the paths found in the saved files
+matching other saved files with the path of the cached copy. The regular
+expressions used to find those paths
+(``django.contrib.staticfiles.storage.CachedStaticFilesStorage.cached_patterns``)
+by default cover the `@import`_ rule and `url()`_ statement of `Cascading
+Style Sheets`_. For example, the ``'css/styles.css'`` file with the content
+
+.. code-block:: css+django
+
+    @import url("../admin/css/base.css");
+
+would be replaced by calling the :meth:`~django.core.files.storage.Storage.url`
+method of the ``CachedStaticFilesStorage`` storage backend, ultimatively
+saving a ``'css/styles.55e7cbb9ba48.css'`` file with the following content:
+
+.. code-block:: css+django
+
+    @import url("/static/admin/css/base.27e20196a850.css");
+
+To enable the ``CachedStaticFilesStorage`` you have to make sure the
+following requirements are met:
+
+* the :setting:`STATICFILES_STORAGE` setting is set to
+  ``'django.contrib.staticfiles.storage.CachedStaticFilesStorage'``
+* the :setting:`DEBUG` setting is set to ``False``
+* you use the ``staticfiles`` :ttag:`static<staticfiles-static>` template tag
+  to refer to your static files in your templates
+* you've collected all your static files by using the :djadmin:`collectstatic`
+  management command
+
+Since creating the MD5 hash can be a performance burden to your website during
+runtime, ``staticfiles`` will automatically try to cache the hashed name for
+each file path using Django's :doc:`caching framework</topics/cache>`. If you
+want to override certain options of the cache backend the storage uses,
+simply specify a custom entry in the :setting:`CACHES` setting named
+``'staticfiles'``. It falls back to using the default cache backend.
+
+.. _`far future Expires headers`: http://developer.yahoo.com/performance/rules.html#expires
+.. _`@import`: http://www.w3.org/TR/CSS2/cascade.html#at-import
+.. _`url()`: http://www.w3.org/TR/CSS2/syndata.html#uri
+.. _`Cascading Style Sheets`: http://www.w3.org/Style/CSS/
+
+.. currentmodule:: django.contrib.staticfiles.templatetags.staticfiles
+
+Template tags
+=============
+
+static
+------
+
+.. templatetag:: staticfiles-static
+
+.. versionadded:: 1.4
+
+Uses the configued :setting:`STATICFILES_STORAGE` storage to create the
+full URL for the given relative path, e.g.:
+
+.. code-block:: html+django
+
+    {% load static from staticfiles %}
+    <img src="{% static "css/base.css" %}" />
+
+The previous example is equal to calling the ``url`` method of an instance of
+:setting:`STATICFILES_STORAGE` with ``"css/base.css"``. This is especially
+useful when using a non-local storage backend to deploy files as documented
+in :ref:`staticfiles-from-cdn`.
 
 Other Helpers
 =============
@@ -251,7 +345,7 @@ files:
       with :class:`~django.template.RequestContext` contexts.
 
     - The builtin template tag :ttag:`static` which takes a path and
-      joins it with the the static prefix :setting:`STATIC_URL`.
+      urljoins it with the static prefix :setting:`STATIC_URL`.
 
     - The builtin template tag :ttag:`get_static_prefix` which populates a
       template variable with the static prefix :setting:`STATIC_URL` to be
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 5c08c66..a7d548a 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -2353,9 +2353,9 @@ static
 
 .. highlight:: html+django
 
-To link to static files Django ships with a :ttag:`static` template tag. You
-can use this regardless if you're using :class:`~django.template.RequestContext`
-or not.
+To link to static files that are saved in :setting:`STATIC_ROOT` Django ships
+with a :ttag:`static` template tag. You can use this regardless if you're
+using :class:`~django.template.RequestContext` or not.
 
 .. code-block:: html+django
 
@@ -2370,6 +2370,17 @@ It is also able to consume standard context variables, e.g. assuming a
     {% load static %}
     <link rel="stylesheet" href="{% static user_stylesheet %}" type="text/css" media="screen" />
 
+.. note::
+
+    The :mod:`staticfiles<django.contrib.staticfiles>` contrib app also ships
+    with a :ttag:`static template tag<staticfiles-static>` which uses
+    ``staticfiles'`` :setting:`STATICFILES_STORAGE` to build the URL of the
+    given path. Use that instead if you have an advanced use case such as
+    :ref:`using a cloud service to serve static files<staticfiles-from-cdn>`::
+
+        {% load static from staticfiles %}
+        <img src="{% static "images/hi.jpg" %}" />
+
 .. templatetag:: get_static_prefix
 
 get_static_prefix
diff --git a/docs/releases/1.4.txt b/docs/releases/1.4.txt
index 2723b42..99f08d3 100644
--- a/docs/releases/1.4.txt
+++ b/docs/releases/1.4.txt
@@ -212,6 +212,29 @@ Additionally, it's now possible to define translatable URL patterns using
 :ref:`url-internationalization` for more information about the language prefix
 and how to internationalize URL patterns.
 
+``static`` template tag
+~~~~~~~~~~~~~~~~~~~~~~~
+
+The :mod:`staticfiles<django.contrib.staticfiles>` contrib app has now a new
+:ttag:`static template tag<staticfiles-static>` to refer to files saved with
+the :setting:`STATICFILES_STORAGE` storage backend. It'll use the storage
+``url`` method and therefore supports advanced features such as
+:ref:`serving files from a cloud service<staticfiles-from-cdn>`.
+
+``CachedStaticFilesStorage`` storage backend
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Additional to the `static template tag`_ the
+:mod:`staticfiles<django.contrib.staticfiles>` contrib app now has a
+:class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage` which
+caches the files it saves (when running the :djadmin:`collectstatic`
+management command) by appending the MD5 hash of the file's content to the
+filename. For example, the file ``css/styles.css`` would also be saved as
+``css/styles.55e7cbb9ba48.css``
+
+See the :class:`~django.contrib.staticfiles.storage.CachedStaticFilesStorage`
+docs for more information.
+
 Minor features
 ~~~~~~~~~~~~~~
 
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/absolute.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/absolute.css
new file mode 100644
index 0000000..e64e7cc
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/documents/cached/absolute.css
@@ -0,0 +1 @@
+@import url("/static/cached/styles.css");
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/denorm.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/denorm.css
new file mode 100644
index 0000000..27b9a34
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/documents/cached/denorm.css
@@ -0,0 +1 @@
+@import url("..//cached///styles.css");
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/other.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/other.css
new file mode 100644
index 0000000..e69de29
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/relative.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/relative.css
new file mode 100644
index 0000000..40c4a25
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/documents/cached/relative.css
@@ -0,0 +1,2 @@
+@import url("../cached/styles.css");
+@import url("absolute.css");
\ No newline at end of file
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/styles.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/styles.css
new file mode 100644
index 0000000..84936d1
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/documents/cached/styles.css
@@ -0,0 +1 @@
+@import url("cached/other.css");
\ No newline at end of file
diff --git a/tests/regressiontests/staticfiles_tests/project/documents/cached/url.css b/tests/regressiontests/staticfiles_tests/project/documents/cached/url.css
new file mode 100644
index 0000000..184e254
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/documents/cached/url.css
@@ -0,0 +1 @@
+@import url("https://www.djangoproject.com/m/css/base.css");
\ No newline at end of file
diff --git a/tests/regressiontests/staticfiles_tests/project/site_media/static/testfile.txt b/tests/regressiontests/staticfiles_tests/project/site_media/static/testfile.txt
new file mode 100644
index 0000000..4d92dbe
--- /dev/null
+++ b/tests/regressiontests/staticfiles_tests/project/site_media/static/testfile.txt
@@ -0,0 +1 @@
+Test!
\ No newline at end of file
diff --git a/tests/regressiontests/staticfiles_tests/tests.py b/tests/regressiontests/staticfiles_tests/tests.py
index 77b771d..ed276bb 100644
--- a/tests/regressiontests/staticfiles_tests/tests.py
+++ b/tests/regressiontests/staticfiles_tests/tests.py
@@ -8,8 +8,9 @@ import sys
 import tempfile
 from StringIO import StringIO
 
+from django.template import loader, Context
 from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
 from django.core.files.storage import default_storage
 from django.core.management import call_command
 from django.test import TestCase
@@ -48,6 +49,18 @@ class StaticFilesTestCase(TestCase):
     def assertFileNotFound(self, filepath):
         self.assertRaises(IOError, self._get_file, filepath)
 
+    def render_template(self, template, **kwargs):
+        if isinstance(template, basestring):
+            template = loader.get_template_from_string(template)
+        return template.render(Context(kwargs)).strip()
+
+    def assertTemplateRenders(self, template, result, **kwargs):
+        self.assertEqual(self.render_template(template, **kwargs), result)
+
+    def assertTemplateRaises(self, exc, template, result, **kwargs):
+        self.assertRaises(exc, self.assertTemplateRenders, template, result, **kwargs)
+
+
 StaticFilesTestCase = override_settings(
     DEBUG = True,
     MEDIA_URL = '/media/',
@@ -257,6 +270,81 @@ TestBuildStaticNonLocalStorage = override_settings(
 )(TestBuildStaticNonLocalStorage)
 
 
+class TestBuildStaticCachedStorage(BuildStaticTestCase):
+    """
+    Tests for the Cache busting storage
+    """
+    @classmethod
+    def setUpClass(cls):
+        storage.configured_storage._wrapped = empty
+
+    def tearDown(self):
+        storage.configured_storage._wrapped = empty
+
+    def cached_file_path(self, relpath):
+        template = "{%% load static from staticfiles %%}{%% static '%s' %%}"
+        fullpath = self.render_template(template % relpath)
+        return fullpath.replace(settings.STATIC_URL, '')
+
+    def test_template_tag_return(self):
+        """
+        Test the CachedStaticFilesStorage backend.
+        """
+        self.assertTemplateRaises(SuspiciousOperation, """
+            {% load static from staticfiles %}{% static "does/not/exist.png" %}
+            """, "/static/does/not/exist.png")
+        self.assertTemplateRenders("""
+            {% load static from staticfiles %}{% static "test/file.txt" %}
+            """, "/static/test/file.dad0999e4f8f.txt")
+        self.assertTemplateRenders("""
+            {% load static from staticfiles %}{% static "cached/styles.css" %}
+            """, "/static/cached/styles.5653c259030b.css")
+
+    def test_template_tag_simple_content(self):
+        relpath = self.cached_file_path("cached/styles.css")
+        self.assertEqual(relpath, "cached/styles.5653c259030b.css")
+        with storage.configured_storage.open(relpath) as relfile:
+            content = relfile.read()
+            self.assertFalse("cached/other.css" in content)
+            self.assertTrue("/static/cached/other.d41d8cd98f00.css" in content)
+
+    def test_template_tag_absolute(self):
+        relpath = self.cached_file_path("cached/absolute.css")
+        self.assertEqual(relpath, "cached/absolute.cc80cb5e2eb1.css")
+        with storage.configured_storage.open(relpath) as relfile:
+            content = relfile.read()
+            self.assertFalse("/static/cached/styles.css" in content)
+            self.assertTrue("/static/cached/styles.5653c259030b.css" in content)
+
+    def test_template_tag_denorm(self):
+        relpath = self.cached_file_path("cached/denorm.css")
+        self.assertEqual(relpath, "cached/denorm.363de96e9b4b.css")
+        with storage.configured_storage.open(relpath) as relfile:
+            content = relfile.read()
+            self.assertFalse("..//cached///styles.css" in content)
+            self.assertTrue("/static/cached/styles.5653c259030b.css" in content)
+
+    def test_template_tag_relative(self):
+        relpath = self.cached_file_path("cached/relative.css")
+        self.assertEqual(relpath, "cached/relative.298ff891a8d4.css")
+        with storage.configured_storage.open(relpath) as relfile:
+            content = relfile.read()
+            self.assertFalse("../cached/styles.css" in content)
+            self.assertFalse('@import "styles.css"' in content)
+            self.assertTrue("/static/cached/styles.5653c259030b.css" in content)
+
+    def test_template_tag_url(self):
+        relpath = self.cached_file_path("cached/url.css")
+        self.assertEqual(relpath, "cached/url.615e21601e4b.css")
+        with storage.configured_storage.open(relpath) as relfile:
+            self.assertTrue("https://" in relfile.read())
+
+
+TestBuildStaticCachedStorage = override_settings(
+    STATICFILES_STORAGE='django.contrib.staticfiles.storage.CachedStaticFilesStorage',
+)(TestBuildStaticCachedStorage)
+
+
 if sys.platform != 'win32':
     class TestBuildStaticLinks(BuildStaticTestCase, TestDefaults):
         """
@@ -418,3 +506,14 @@ class TestStaticfilesDirsType(TestCase):
 TestStaticfilesDirsType = override_settings(
     STATICFILES_DIRS = 'a string',
 )(TestStaticfilesDirsType)
+
+
+class TestTemplateTag(StaticFilesTestCase):
+
+    def test_template_tag(self):
+        self.assertTemplateRenders("""
+            {% load static from staticfiles %}{% static "does/not/exist.png" %}
+            """, "/static/does/not/exist.png")
+        self.assertTemplateRenders("""
+            {% load static from staticfiles %}{% static "testfile.txt" %}
+            """, "/static/testfile.txt")
