{ "info": { "author": "James Addison", "author_email": "code@scottisheyes.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Topic :: Internet :: WWW/HTTP :: WSGI" ], "description": "DJANGO 1.4+ USERS:\n==================\nYou should probably look to use Django's included ``static`` template tag rather than use django-cachebuster. Why include a 3rd party app when you can use the built-in functionality?\n\n\n\ndjango-cachebuster -- A backwards-compatible Django 1.3+ ready set of cache-busting template tags\n=================================================================================================\n\nOverview\n--------\n\n**django-cachebuster** is a Django app containing two template tags: ``static`` and ``media``. Each tag will use the file last modified timestamp by default to 'bust' web browser file caches. ``static`` is meant for your site's JavaScript, CSS and standard images. ``media`` is intended for user uploaded content like avatars, videos and other files. CloudFront and other content delivery networks are supported.\n\n\nDescription\n-----------\n\nAll of the existing file cache busting techniques seem to be Django versions 1.2.x and lower oriented - meaning they don't support the new ``django.contrib.staticfiles`` paradigm. This app addresses this functionality gap.\n\nAdditionally, there are some optimizations (see **Configuration** below) that can be enabled to minimize file modification date disk reads.\n\n\nRequirements\n------------\n\n- Python 2.6 (May work with prior versions, but untested - please report)\n- Django 1.2.x, 1.3.x (May work with prior versions, but untested - please report)\n\n\nInstallation\n------------\n\nCopy or symlink the 'cachebuster' package into your django project directory or install it by running one of the following commands:\n\n::\n\n python setup.py install\n\n::\n\n pip install django-cachebuster\n\n::\n\n easy_install django-cachebuster\n\nNow, add ``cachebuster`` to your ``INSTALLED_APPS`` in your project's ``settings.py`` module.\n\n\nTemplate Usage\n----------------------\n\nTo use these cache-busting template tags, you'll need to load the template tag module at the top of each template with ``{% load cachebuster %}``. Alternatively, as these tags will most likely be used in most of a project's templates, you can tell Django to auto-load them without the requisite ``{% load cachebuster %}`` by adding the following to your ``settings.py``:\n\n::\n\n from django.template.loader import add_to_builtins\n add_to_builtins('cachebuster.templatetags.cachebuster')\n\n``{% static filename %}`` attempts to use the ``CACHEBUSTER_UNIQUE_STRING`` (see **Configuration** below) setting to get a cached value to append to your static URLs (ie. ``STATIC_URL``). If ``CACHEBUSTER_UNIQUE_STRING`` is not set, it falls back to the last date modified of the file. If ``CACHEBUSTER_UNIQUE_STRING`` is used, you can force last-date-modified behaviour by adding ``True`` into the tag statement like so: ``{% static filename True %}``. For example\n\n::\n\n \n \n\nThis would yield something along the lines of:\n\n::\n\n \n \n\n``{% media filename %}`` is similar but has slightly different behaviour, as the file content has a different origin (user uploaded content like avatars, videos, etc.) and cannot depend on any git comment hash. This is why there is no behaviour other than the last modified date method for MEDIA_URL files.\n\n::\n\n \n\nwould result in something like this:\n\n::\n\n \n\n\nConfiguration\n--------------------\n\n**django-cachebuster** supports two methods of 'busting'. Appending a unique string (by default, this is the last modified datetime of the file) as a query string parameter is the easy, default behaviour. For more advanced requirements such as content distribution network (CDN, such as CloudFront) scenarios, there is also the ability to prepend the unique string.\n\nTo start using it in it's simplest form right now, see the **Template Usage** section. Want more from **django-cachebuster**? Read on.\n\n``CACHEBUSTER_UNIQUE_STRING``: **optional**; defaults to the file's last modified timestamp.\n\nThis is a simple performance optimization that minimizes accessing the file system to get a file's last modified timestamp. This optimization is only used for static files (not media/user-generated files) as only static files are usually version-controlled.\n\nTo set ``CACHEBUSTER_UNIQUE_STRING``, you would mostly likely use a provided 'detector' or write your own (please contribute new ones!). For example, if you use Git as your source control, you can use the provided ``git`` detector. It simply traverses the Django project's path looking for the ``.git`` folder, and then extracts the current commit hash. This hash is cached and used for subsequent cache-busting. In your settings.py:\n\n::\n\n from cachebuster.detectors import git\n CACHEBUSTER_UNIQUE_STRING = git.unique_string(__file__)\n\nor if you wanted it to be a short busting string:\n\n::\n\n from cachebuster.detectors import git\n CACHEBUSTER_UNIQUE_STRING = git.unique_string(__file__)[:8]\n\n``__file__`` must be passed in so that **django-cachebuster** operates in the context of the Django project's settings.py file. If it wasn't passed in, django-cachebuster would only have its own context from which to grab the ``.git`` directory, not that of the user's project. (An alternative to this is to use Python's ``inspect`` module - but there are some warnings around using it.)\n\n``CACHEBUSTER_PREPEND_STATIC``: **optional**; defaults to ``False``.\n\n``CACHEBUSTER_PREPEND_MEDIA``: **optional**; defaults to ``False``.\n\nIf CloudFront or another CDN that ignores query string parameters is used, ``CACHEBUSTER_PREPEND_STATIC`` will need to be set to ``True``. For static files, this prepends the unique string instead of appending it as a query string parameter. ``CACHEBUSTER_PREPEND_MEDIA`` does the same for media files. For example, with ``CACHEBUSTER_PREPEND_STATIC`` set to True, the rendered output becomes:\n\n::\n\n \n\nWith ``CACHEBUSTER_PREPEND_STATIC`` set to False:\n\n::\n\n \n\nUsing this prepending method raises a couple of development environment issues, however. Assuming Django 1.3 or higher is used, ``./manage.py runserver`` will automatically attempt to serve static (not media, however) files on its own without any urls.py changes; this standard method of serving does not work in this scenario. To prevent this default Django behaviour, the development server should be started with the following command:\n\n::\n\n ./manage.py runserver --nostatic\n\nAlso when using the prepending method in a development environment, to support serving files from both ``{% static %}`` and ``{{ STATIC_URL }}`` (as well as ``{% media %} and ``{{ MEDIA_URL }}``), Django's default ``serve`` views need to be replaced with the following in your ``urls.py``:\n\n::\n\n if settings.DEBUG:\n urlpatterns += patterns('',\n url(r'^static/(?P.*)$', 'cachebuster.views.static_serve', {'document_root': settings.STATIC_ROOT,}),\n url(r'^media/(?P.*)$', 'cachebuster.views.media_serve', {'document_root': settings.MEDIA_ROOT,}),\n )\n\nThis is because both the prepended and the non-prepended paths need to be tested to support the above-mentioned scenarios.\n\n\nTroubleshooting\n----------------------\n\n**My date-based cache-busting unique strings keep updating even though my assets aren't changing**\n\nAre you deploying your assets from a source control system such as Subversion or Git? By default, those systems set the last modified date of checked-out files to their check-out dates, **not** the original files' last modified dates. To fix this on Subversion, set ``use-commit-times=true`` in your Subversion config. In Git this is a little harder; it requires adding a Git post-checkout hook (or updating your deployment script). For more instructions on doing this, see the answers to `this question on Stack Overflow `_.\n\n\nNotes\n-----\n\nPlease feel free to send a pull request with fixes and in particular, additional ``detectors`` to improve the usefulness of this app. Maybe for ``svn``, ``hg``, etc?\n\n\nSource\n------\n\nThe latest source code can always be found here: `github.com/ambitioninc/django-cachebuster `_\n\n\nCredits\n-------\n\ndjango-cachebuster is maintained by `James Addison `_.\n\n\nLicense\n-------\n\ndjango-cachebuster is Copyright (c) 2011, James Addison. It is free software, and may be redistributed under the terms specified in the LICENSE file.\n\n\nQuestions, Comments, Concerns:\n------------------------------\n\nFeel free to open an issue here: `github.com/ambitioninc/django-cachebuster/issues `_", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/ambitioninc/django-cachebuster", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "ambition-django-cachebuster", "package_url": "https://pypi.org/project/ambition-django-cachebuster/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ambition-django-cachebuster/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/ambitioninc/django-cachebuster" }, "release_url": "https://pypi.org/project/ambition-django-cachebuster/0.3/", "requires_dist": null, "requires_python": null, "summary": "Django 1.3, Python 2.7/3.5 ready cache busting app", "version": "0.3" }, "last_serial": 2658961, "releases": { "0.3": [ { "comment_text": "", "digests": { "md5": "e76c552b96ccb325c3858e557a5a6204", "sha256": "2a1b6892679c307d838931eecb19e5ddd0bed1371f2d86c13a14b53765ca6a71" }, "downloads": -1, "filename": "ambition_django_cachebuster-0.3-py2-none-any.whl", "has_sig": false, "md5_digest": "e76c552b96ccb325c3858e557a5a6204", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 13805, "upload_time": "2017-02-21T21:36:09", "url": "https://files.pythonhosted.org/packages/03/5e/a1f9851572031a4d28b5f3c764661b3b52be58e135b8abd29ee4363d91b1/ambition_django_cachebuster-0.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "617a8868675458d71379fafa6fb2795d", "sha256": "a33b16b17f3eb2dbab2d602a662c96dac5472eef7094819bfbacfb2f35e55f12" }, "downloads": -1, "filename": "ambition-django-cachebuster-0.3.tar.gz", "has_sig": false, "md5_digest": "617a8868675458d71379fafa6fb2795d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10757, "upload_time": "2017-02-21T21:36:07", "url": "https://files.pythonhosted.org/packages/6e/73/9bb66ad2f8a1fd3936b0957df3f2a80501044071ebb7d0f9b262bda401ac/ambition-django-cachebuster-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "e76c552b96ccb325c3858e557a5a6204", "sha256": "2a1b6892679c307d838931eecb19e5ddd0bed1371f2d86c13a14b53765ca6a71" }, "downloads": -1, "filename": "ambition_django_cachebuster-0.3-py2-none-any.whl", "has_sig": false, "md5_digest": "e76c552b96ccb325c3858e557a5a6204", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 13805, "upload_time": "2017-02-21T21:36:09", "url": "https://files.pythonhosted.org/packages/03/5e/a1f9851572031a4d28b5f3c764661b3b52be58e135b8abd29ee4363d91b1/ambition_django_cachebuster-0.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "617a8868675458d71379fafa6fb2795d", "sha256": "a33b16b17f3eb2dbab2d602a662c96dac5472eef7094819bfbacfb2f35e55f12" }, "downloads": -1, "filename": "ambition-django-cachebuster-0.3.tar.gz", "has_sig": false, "md5_digest": "617a8868675458d71379fafa6fb2795d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10757, "upload_time": "2017-02-21T21:36:07", "url": "https://files.pythonhosted.org/packages/6e/73/9bb66ad2f8a1fd3936b0957df3f2a80501044071ebb7d0f9b262bda401ac/ambition-django-cachebuster-0.3.tar.gz" } ] }