mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Refs #31949 -- Made @never_cache and @cache_control() decorators to work with async functions.
Thanks Carlton Gibson and Mariusz Felisiak for reviews.
This commit is contained in:
parent
a14ddc8cfc
commit
4dfc6ff8a8
5 changed files with 182 additions and 26 deletions
|
@ -73,6 +73,31 @@ from an async view, you will trigger Django's
|
|||
:ref:`asynchronous safety protection <async-safety>` to protect your data from
|
||||
corruption.
|
||||
|
||||
Decorators
|
||||
----------
|
||||
|
||||
.. versionadded:: 5.0
|
||||
|
||||
The following decorators can be used with both synchronous and asynchronous
|
||||
view functions:
|
||||
|
||||
* :func:`~django.views.decorators.cache.cache_control`
|
||||
* :func:`~django.views.decorators.cache.never_cache`
|
||||
|
||||
For example::
|
||||
|
||||
from django.views.decorators.cache import never_cache
|
||||
|
||||
|
||||
@never_cache
|
||||
def my_sync_view(request):
|
||||
...
|
||||
|
||||
|
||||
@never_cache
|
||||
async def my_async_view(request):
|
||||
...
|
||||
|
||||
Queries & the ORM
|
||||
-----------------
|
||||
|
||||
|
|
|
@ -117,6 +117,10 @@ client-side caching.
|
|||
:func:`~django.utils.cache.patch_cache_control` for the details of the
|
||||
transformation.
|
||||
|
||||
.. versionchanged:: 5.0
|
||||
|
||||
Support for wrapping asynchronous view functions was added.
|
||||
|
||||
.. function:: never_cache(view_func)
|
||||
|
||||
This decorator adds an ``Expires`` header to the current date/time.
|
||||
|
@ -127,6 +131,10 @@ client-side caching.
|
|||
|
||||
Each header is only added if it isn't already set.
|
||||
|
||||
.. versionchanged:: 5.0
|
||||
|
||||
Support for wrapping asynchronous view functions was added.
|
||||
|
||||
.. module:: django.views.decorators.common
|
||||
|
||||
Common
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue