Control Page Caching Manually

Sometimes caching can cause site visitors to see outdated or incorrect content. For such cases you can manually control or disable caching for your site pages.

You can manually control page caching by:

  • Disabling page caching in the editor.
  • Setting a lifespan for page caches in the editor.
  • Using code to invalidate page caches when necessary.

Disable caches or manage the cache lifespan in the editor

If the data on your site page changes very frequently, you can disable caching for that page, ensuring your site is always displaying the most up-to-date information. If the data on your page updates regularly, you can set your page's cache to clear and refresh at an interval that matches your needs.

To disable or manage caching:

  1. In the editor, click the Pages pages icon icon on the left sidebar to open the Site Pages panel.

  2. Click the More Actions show more icon for the page you want to control caching, and then select Settings. This opens the Page Settings panel for that page.

  3. Click Advanced Settings and turn on the Manually control caching for this page toggle.

  4. Open the How often do you want to reset this page's cache? dropdown.

    • To disable caching for the page, select Never (disable caching).
    • To manage the cache lifespan for the page, select the time interval that best suits your page's needs.

Invalidate cache with code

If your page’s data only updates occasionally, you can keep automatic caching enabled and add code to the page to invalidate the cache when the page's data is expected to be updated.

Call the invalidate() method from the wix-site-backend module in your backend code.

Copy

Important: The invalidate() method invalidates the cache for the whole site, not just the page where you run the code.

See also

Did this help?