Order JSON keys by default to avoid trashing HTTP caches

This commit is contained in:
Armin Ronacher 2013-06-01 19:24:03 +01:00
parent 3d9055b3b7
commit 77d293cf49
5 changed files with 57 additions and 1 deletions

View file

@ -149,6 +149,17 @@ The following configuration values are used internally by Flask:
unicode strings. ``jsonfiy`` will
automatically encode it in ``utf-8``
then for transport for instance.
``JSON_SORT_KEYS`` By default Flask will serialize JSON
objects in a way that the keys are
ordered. This is done in order to
ensure that independent of the hash seed
of the dictionary the return value will
be consistent to not trash external HTTP
caches. You can override the default
behavior by changing this variable.
This is not recommended but might give
you a performance improvement on the
cost of cachability.
``JSONIFY_PRETTYPRINT_REGULAR`` If this is set to ``True`` (the default)
jsonify responses will be pretty printed
if they are not requested by an
@ -197,7 +208,7 @@ The following configuration values are used internally by Flask:
``PREFERRED_URL_SCHEME``
.. versionadded:: 0.10
``JSON_AS_ASCII``, ``JSONIFY_PRETTYPRINT_REGULAR``
``JSON_AS_ASCII``, ``JSON_SORT_KEYS``, ``JSONIFY_PRETTYPRINT_REGULAR``
Configuring from Files
----------------------