Serial numbers used for front-end and back-end caching keys/URLs.
These functions generate stable serial numbers based on the content shipped with the product (static media files, templates, locales). These can be used in various cache keys, ETags, and URLs to help keep content in cache until it changes on disk.
Generate a media serial number for static media files.
The media serial number can be appended to a media filename in order to make a URL that can be cached forever without fear of change. The next time the file is updated and the server is restarted, a new path will be accessed and cached.
This will crawl the media files (using directories in
MEDIA_SERIAL_DIRSif specified, or all of
STATIC_ROOTotherwise), figuring out the latest timestamp, and return that value.
Generate a template-based AJAX serial number for requests and ETags.
The serial number can be appended to filenames involving dynamic loads of URLs in order to make a URL that can be cached forever without fear of change.
This will crawl the template files (using directories in
TEMPLATE_DIRS), figuring out the latest timestamp, and return that value.
Generate a locale serial for the given set of packages.
This will be equal to the most recent mtime of all the .mo files that contribute to the localization of the given packages.
Unlike the other serial-generation functions, this will return the value, rather than setting it on
Parameters: packages (list of unicode) – A list of Python module paths containing
Returns: The resulting serial number. Return type: int
Generate both static media and AJAX serial numbers.
This is a wrapper around
generate_ajax_serial(), which generates all the serial numbers in one go.
This should be called early in the startup, such as in the site’s main