Is there a way to exclude from page caching for templates like:
/wp-content/themes/theme_name/views/en/base.twig
Because we have some variables inside that should be relative, like user country, which is based on user location.
Is it possible to delete the page cache of the homepage every 30 minutes using a cron task, but only delete all other pages once a day?
If so, what does this command look like and how can I set this up in WordPress?
Thanks & best regards
Christian
Inline CSS for browser scrollbar width is hardcoded in output based on current browser user-agent in inc/dynamic-css/block-editor-compatibility.php
at line 217:
// Detect the operating system and set the typical scrollbar width.
$user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : '';
$scrollbar_widths = [
'Win' => '17px',
'Mac' => '15px',
'Linux' => '15px',
];
$scrollbar_width = '0';
foreach ( $scrollbar_widths as $platform => $width ) {
if ( strpos( $user_agent, $platform ) !== false ) {
$scrollbar_width = $width;
break;
}
}
$dynamic_css .= '
:root {
[...some lines removed...]
--ast-scrollbar-width: ' . $scrollbar_width . ';
}
A wp_get_attachment_image_attributes
filter changes src
attribute of header image in output based on current browser user-agent in inc/markup-extras.php
line 2036:
if ( astra_check_is_ie() ) {
// Replace header logo url to retina logo url.
$attr['src'] = $retina_logo;
}
A get_custom_logo
filter changes src
attribute of header image in output based on current browser user-agent in inc/markup-extras.php
line 290:
if ( astra_check_is_ie() ) {
// Replace header logo url to retina logo url.
$attr['src'] = $retina_logo;
}
The above used function astra_check_is_ie()
can be found inc/extras.php
at line 301:
/**
* Function to check if it is Internet Explorer.
*
* @return true | false boolean
*/
function astra_check_is_ie() {
$is_ie = false;
if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
$ua = htmlentities( sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ), ENT_QUOTES, 'UTF-8' ); // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Need to check if its ie.
if ( strpos( $ua, 'Trident/7.0' ) !== false ) {
$is_ie = true;
}
}
return apply_filters( 'astra_check_is_ie', $is_ie );
}
Astra 4.8.11
]]>I noticed that when updating a product via the quick edit, the cached pages are not purged.
For example, a tag is added. If it is done through the product page, then the cache of various pages is purged. However, if the edit is being made via the “quick edit” option, then corresponding page caches (eg tag/category pages) are not purged.
Note: I am using page cache with Disk: Enhanced
Thank you!
]]>We have noticed a strange case where W3 Total Cache creates huge directories with a recursive nature. If they grow too much, they need to be deleted through ftp because they crash the clear cache functionality.
The offending files are under /wp-content/cache/page_enhanced/domain/search
.
/search/
url. It is a 404. The search functionality is the default, using ?s=
. But under /search/bla
it would search for bla
. I guess this is default behavior?/search/
directory, there are many directories like:%2525252525252525252525252525257bsearch_term_string%2525252525252525252525252525257d/
%25252525252525252525252525257bsearch_term_string%25252525252525252525252525257d/
%252525252525252525252525257bsearch_term_string%252525252525252525252525257d/
%2525252525252525252525257bsearch_term_string%2525252525252525252525257d/
%25252525252525252525257bsearch_term_string%25252525252525252525257d/
%252525252525252525257bsearch_term_string%252525252525252525257d/
%2525252525252525257bsearch_term_string%2525252525252525257d/
%25252525252525257bsearch_term_string%25252525252525257d/
%252525252525257bsearch_term_string%252525252525257d/
%2525252525257bsearch_term_string%2525252525257d/
%25252525257bsearch_term_string%25252525257d/
%252525257bsearch_term_string%252525257d/
%2525257bsearch_term_string%2525257d/
%25257bsearch_term_string%25257d/
%257bsearch_term_string%257d/
%7bsearch_term_string%7d/
label/--
This motive keeps growing. Inside each directory there are more like:
/wp-content/cache/page_enhanced/www.__domain__/search/%7bsearch_term_string%7d/__domain__/__domain__/privacy-policy/__domain__/__domain__/__domain__/__domain__/__domain__/__domain__/privacy-policy/__domain__/privacy-policy/__domain__/privacy-policy
in some of those (even the ones in the middle) there are 2 folder inside, 1 with the domain name/site and 1 privacy-policy. After randomly “walking” through these, at some point there are the .html and .html_gzip files. That is a page with the test results as if the search query was:
{search_term_string}/__domain__/__domain__/privacy-policy/__domain__/__domain__/__domain__/__domain__/__domain__/__domain__/privacy-policy/__domain__/privacy-policy/__domain__/privacy-policy/__domain__/privacy-policy/__domain__/__domain__/__domain__/privacy-policy
I removed the domain but the {search_term_string}
is literally like that. It is as if there are many searched under https://__domain__/search/{search_term_string}/__domain__/__domain__/privacy-policy/...
.
Any clues what is happening? Why are all these cached?
I guess I could disable page cache for anything under /search/
but this does not really explain what is happening. I could also disable WordPress search since it is not needed for that site, but I would prefer not to.
Thank you!
PS: the option Cache URIs with query string variables is unchecked (and cannot actually be enabled)
]]>is it possible to cache certain page only in case they are loaded manually by a site visitor. I am primarily thinking of product filter result pages, like for example https://www.pflanzkompass.at/elemente/?wpf_filter_bluetenfarbe=rot&groupwpf__bluetenfarbe_crtebp2au=1&wpf_filter_lichtbedarf=vollsonnig&wpf_fbv=1
If that page was cached it would load much faster when the user navigates back after having viewed a single product.
However, I would not want any pages with parameters be pre-cached as they are not, of course, in the sitemap.
Best regards
Martin
]]>Firstly, thanks for building this very useful plugin and making it freely available.
I’ve been experimenting with the page cache and cache priming options. I see that pages listed in the priming sitemap will only be regenerated at the set interval if the current cached version has expired. I understand this makes sense generally, but is it possible to force the cached version(s) to be updated at the specified interval?
Note that I’ve set DISABLE_WP_CRON to true and am running wp-cron via a cron job.
Regards
]]>We are getting a new Site Health error: “Page cache is detected but the server response time is still slow.” I have searched for an answer to this question for days – trying different solutions, including removing .js code and installing an additional plugin for optimization: WP Optimize. I found a few threads on this forum but nothing has worked for me.
We have been using W3 Total Cache since 2018. Can you help?
cache-control
,?expires
.Thank you,
Tina
]]><?php
/*
* Add this to your theme functions.php, or add to a plugin.
*
*/
/**
* Clear the SpinupWP Cache for the entire website.
*/
function clear_spinup_cache(): bool
{
if (! class_exists('SpinupWp\Cache')) {
return false;
}
$class_spinup_admin = new SpinupWp\AdminBar('/wp-content/plugins/spinupwp/');
$class_spinup_cli = new SpinupWp\Cli;
$class_spinup_cache = new SpinupWp\Cache($class_spinup_admin, $class_spinup_cli);
if ($class_spinup_cache->is_page_cache_enabled()) {
$purge = $GLOBALS['spinupwp']->cache->purge_page_cache();
$type = 'Page cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
helpers\log("Purging {$type} result: {$res}");
}
if ($class_spinup_cache->is_object_cache_enabled()) {
$purge = $GLOBALS['spinupwp']->cache->purge_object_cache();
$type = 'Object cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
// Commenting out because this helper class is unique to stafflink.
//helpers\log("Purging {$type} result: {$res}");
}
return true;
}
/**
* Clear the cache for the specific URL only.
*/
function clear_spinup_cache_for_this_url(): bool
{
// exit quickly if spinup plugin does not exist
if (! class_exists('SpinupWp\Cache')) {
return false;
}
$url = home_url().'/wp-content/plugins/spinupwp/';
$class_spinup_admin = new SpinupWp\AdminBar($url);
$class_spinup_cli = new SpinupWp\Cli;
$class_spinup_cache = new SpinupWp\Cache($class_spinup_admin, $class_spinup_cli);
if ($class_spinup_cache->is_page_cache_enabled()) {
$url = $_SERVER['HTTP_REFERER'];
$purge = $GLOBALS['spinupwp']->cache->purge_url($url);
$type = 'URL page cache';
$res = $purge ? 'Cleared' : 'Not Cleared';
// Log page cache if success
// Commented out because this helper class is unique to STAFFLINK.
//helpers\log("Purging {$type} result: {$res}");
}
}
]]>