Commit 3b79fec6 by Timothée Peignier

add signals docs. close #13

parent bdf4995d
...@@ -137,8 +137,6 @@ Other settings ...@@ -137,8 +137,6 @@ Other settings
Regulates whether or not to add a "version number" to the outputted files Regulates whether or not to add a "version number" to the outputted files
filename with for use with “far future Expires”. filename with for use with “far future Expires”.
For more information, see :doc:`farfutureexpires`.
When you specify ``PIPELINE_VERSION`` you will also need to add a placeholder When you specify ``PIPELINE_VERSION`` you will also need to add a placeholder
(which by default is ``?``) for the version number in the ``output_filename`` setting. (which by default is ``?``) for the version number in the ``output_filename`` setting.
......
.. _ref-farfutureexpires:
==================
Far future expires
==================
Details about the "Far future expires" technique, and how to implement it with help from Pipeline
General details and considerations about the "Far future expires" technique
===========================================================================
If you really want to make sure that your CSS and JavaScript files get cached by
the browser (and possibly by proxies), you should use "Far Future Expires".
This means that you send the Expires HTTP-header with a date that is far in the future,
resulting in the file being cached at the client (almost) forever
If you do not specify an Expires header, the files will be requested again,
and the server will respond "*304 Not Modified*" - which means that the file that
the client got in its cache is still up-to-date. *However, a HTTP request will still be made anyway.*
The actual data does not get sent, but there will still be unnecessary HTTP requests, which can be avoided.
Most modern browser implement "*Heuristic expiration*", so it will actually not be
"*304 Not Modified*" for your static files on every request, however, the
`HTTP specification does not specify <http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html>`_ (see section 13.2.2)
how "*Heuristic expiration*" should be handled by the browsers.
Therefore it is recommended to explicitly set the Expires header, to make sure all
browsers cache the files in the preferred way.
This technique obviously has a drawback, when you want to change your files,
you need to change their names, since their URLs will be cached... that's right: forever!
The solution to that is pretty obvious too: change the URLs.
Versionning
===========
If you specify ``PIPELINE_VERSION`` in your configuration, you can add a placeholder
to the filenames to output the version number of the different files.
The filename itself will be changed when any of the source files are updated.
See :doc:`configuration` for more information.
Configuration of web server
===========================
Apache
------
Expires-control in Apache is handled by mod_expires:
See documentation for more information:
* `mod_expires <http://httpd.apache.org/docs/2.2/mod/mod_expires.html>`_
For example ::
<Directory /your/media/root/css>
ExpiresActive on
ExpiresDefault "access plus 10 years"
</Directory>
Apache also allows the specify files by their mime-type ::
ExpiresActive On
ExpiresByType text/css "access plus 10 years"
ExpiresByType application/x-javascript "access plus 10 years"
lighttpd
--------
lighttpd handles Expires similar to Apache, with a module called mod_expire.
* `mod_expire <http://trac.lighttpd.net/trac/wiki/Docs%3AModExpire>`_
For example, set far future headers on all files under ``/media/css/`` and ``/media/js/`` ::
$HTTP["url"] =~ "^/media/css/" {
expire.url = ( "" => "access 10 years" )
}
$HTTP["url"] =~ "^/media/js/" {
expire.url = ( "" => "access 10 years" )
}
nginx
-----
nginx's ``ngx_http_headers_module`` provides the ``expires`` option, which control
the ``Expires`` and ``Cache-Control`` HTTP headers.
* `ngx_http_headers_module <http://wiki.codemongers.com/NginxHttpHeadersModule>`_
For example, this will set expiration to the maximum expiration ::
location /media/js {
expires max;
}
location /media/css {
expires max;
}
...@@ -21,7 +21,7 @@ Table Of Contents ...@@ -21,7 +21,7 @@ Table Of Contents
versioning versioning
templates templates
storages storages
farfutureexpires signals
changelog changelog
Indices and tables Indices and tables
......
.. _ref-signals:
=======
Signals
=======
A list of all signals send by pipeline.
css_compressed
--------------
pipeline.signals.css_compressed
Whenever a css package is compressed, this signal is sent after the compression.
Arguments sent with this signal :
:sender:
The ``Packager`` class that compressed the group.
:package:
The package actually compressed.
:version:
The version identifier if the newly compressed file.
js_compressed
--------------
pipeline.signals.js_compressed
Whenever a js package is compressed, this signal is sent after the compression.
Arguments sent with this signal :
:sender:
The ``Packager`` class that compressed the group.
:package:
The package actually compressed.
:version:
The version identifier if the newly compressed file.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment