# Clearing cache\_page

**URL:** <https://forum.djangoproject.com/t/clearing-cache-page/21314>\
**Category:** Deployment\
**Created:** [June 2, 2023, 1:15pm UTC](https://forum.djangoproject.com/t/clearing-cache-page/21314 "2023-06-02T13:15:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vazark](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/vazark/32/5827_2.png) [@vazark](https://forum.djangoproject.com/u/vazark)\
**Post date:** [June 2, 2023, 1:15pm UTC](https://forum.djangoproject.com/t/clearing-cache-page/21314/1 "2023-06-02T13:15:20Z")

</div>

Hello,

A few of our endpoints serve up a set of “constants” as configured in the DB (imagine a list of countries, cities). So to optimise speed, we cached them with the cache\_page decorator.

We’d like any changes made to be reflected instantaneously. I’d like to clear the cache using signals. Is there any function to obtain the cache key based on the URL of a view?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 2, 2023, 1:51pm UTC](https://forum.djangoproject.com/t/clearing-cache-page/21314/2 "2023-06-02T13:51:33Z")

</div>

There’s a function, [`get_cache_key`](https://docs.djangoproject.com/en/4.2/ref/utils/#django.utils.cache.get_cache_key), which is passed a request.

A full request - with headers - is needed to be able to support [the `Vary` options](https://docs.djangoproject.com/en/4.2/topics/cache/#using-vary-headers). Just having the URL is not sufficient.

---

<div class="post-metadata">

**Author:** ![cehceh](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/cehceh/32/3415_2.png) [@cehceh](https://forum.djangoproject.com/u/cehceh)\
**Post date:** [June 2, 2023, 3:01pm UTC](https://forum.djangoproject.com/t/clearing-cache-page/21314/3 "2023-06-02T15:01:00Z")

</div>

I have used this decorator before and it has performed the job

`from django.views.decorators.cache import never_cache`
