<@ULVA73B9P> I am using ```from prefect.cache_pol...
# ask-marvin
s
@Marvin I am using
Copy code
from prefect.cache_policies import NO_CACHE

@task(cache_policy=NO_CACHE)
def some_task():
    do_something
Is there a way to globalize the
cache_policy
?
m
thought for 222.9 seconds
Yes — in Prefect 3.x that’s correct.
NO_CACHE
is a valid cache policy and using
@task(cache_policy=NO_CACHE)
disables task caching for that task. A couple of notes you may find helpful: - Import and usage:
Copy code
from prefect import task
  from prefect.cache_policies import NO_CACHE

  @task(cache_policy=NO_CACHE)
  def my_task(...):
      ...
- If you also want to avoid any in-memory reuse during the same flow run and prevent result persistence, you can add:
Copy code
@task(cache_policy=NO_CACHE, cache_result_in_memory=False, persist_result=False)
-
cache_result_in_memory=False
stops in-run memory caching. -
persist_result=False
controls result storage; it’s independent of caching. For reference: - Caching concepts: Prefect 3.x caching concepts - Cache policies API: prefect.cache_policies API - Task decorator params (incl. cache options): task API reference If your goal is to fully disable both caching and persistence for a specific task, the second example is the most explicit. Want to do this globally or just for a few tasks?