Is there any mean to exclude a *.php
file to WP Super Cache?
I’ve in my single.php
page an include news.php
, the file news.php
contains ten links to my last articles.
So I want to cache single.php
but to exclude news.php
that is included in single.php
.
It is possible? How can I do that?
Rather than incorporating dynamic content into cached pages, you are better off using AJAX to pull dynamic content onto those pages in the browser.
In your
news.php
file, simply have an empty element that will contain the content. Better still, have it contain an AJAX spinner that indicates that content is coming.Then use jQuery to load your news content — this code goes in your theme’s functions.php:
That will load the content every time a visitor navigates to a new page. If your news content doesn’t change much, I recommend you make use of sessionStorage to cache the news content in the browser for the duration of the visit. If you want to limit how long that cache lasts, see Session storage with expiry time.
Follow the steps below to prevent caching of the
news.php
file:Visit the WP Super Cache settings page in your WordPress administration dashboard (Settings > WP Super Cache).
Visit the ‘Advanced’ tab along the top of that page
Scroll down to the Accepted Filenames & Rejected URIs heading
Look for the box with the description of:
Enter
news.php
on a new line in the textbox below the descriptionClick Save Files »