Hi,
I’ve faced with the same error: https://www.ads-software.com/support/topic/500s-on-redirects-call-to-a-member-function-get_queried_object_id-on-null/
Is it possible that it can be fixed or is development of this plugin stopped?
]]>for some reason all my headers have the pragma: no-cache
is there a way this plugin can override that header as well?
On my virtual host to cache page is used varnish but is not customizable. I need to prevent cache on this page or this request modifying the Ajax call to set the ‘Cache-Control’ header to ensure that the call is not cached by Varnish.
This is the page/ajax req(this is the varnish conf):
if (req.url ~ “^/(cart|my-account|checkout|addons)”) {
return (pass);
}
if ( req.url ~ “\?add-to-cart=” ) {
return (pass);
}
I doesn’t understand if i can do it with your plugin.
]]>Hi,
Plugin adds “public” only if $max_age is 0 AND $s_maxage is not 0.
Line 203 https://plugins.trac.www.ads-software.com/browser/cache-control/trunk/cache-control.php#L203
To be Google CDN complain it is better to add “public” even if $max_age is not 0 OR $s_maxage is not 0.
Cacheability: https://cloud.google.com/cdn/docs/caching#cacheability
]]>Hi,
We need Expires
directive to prevent apache Cache-Control
duplication.
> When the Expires
header is already part of the response generated by the server, this module does not change or add an Expires
or Cache-Control
header.
Hi,
It’s been a while since I had that issue on most of wordpress sites using this plugin. In the mean time I just disabled this plugin using varnish fallback of 2min cache, but would be nice to get control back.
With one site using TagDiv Newspaper (version 9, I haven’t updated yet to their 10.x) (https://demo.tagdiv.com/newspaper/), soon as I activate this plugin, all pages of the site throws this header.
cache-control: no-cache, must-revalidate, max-age=0;
Seams to do with the theme used, I have other sites were this header comes and goes, or only on landing page… but could not identify the issue. Very strange that it only does it sometimes on some pages.
perhaps the theme uses a function that triggers this… any clue ?
thanks
]]>Hi,
Will the plugin leave any settings if I disable it? I would like to install it and check the performance on GTMetrix and pagespeedinsights.
I use wp rocket (cache) and wpcompress (images)
Thank you
]]>Does this plugin include that? I don’t see it showing up.
]]>Juste to let you know, I’ve started to write a Cache-Control plugin that one can rely on.
I’m managing around 100 wp behind reverse proxy.
Some are on heavy load (100k+ daily visitors) and I got tired of rescuing servers each time one plugin or an other blows all up.
So I’ll make it very simple (all ready > 500 lines ?) and I’ll try to make it smart (aka detect if settings imply reverse proxy) and cleanup any Set-Cookie / Pragma or Expire that could get in the way.
For most of it, I’m picking in this plugin the bits that have proven good (I’ve been using it for as long as I can remember messing with wp)
It needs a good refactoring… and a smarter admin (pain full to set one by one).
I hate writing php… and even more wordpress.
My php is basic but I have 15years experience as sysadmin + dev and have switched to node
I’ll juste make the part that does the job – sets/fixes the headers – but I won’t get near making a wp-admin option page… as I said, I have no joy doing php, and wp-admin will just make me cry.
If anyone is up for doing the handy option page… I’m open to ideas and help.
Other then that I’ll juste use a json to manage settings.
Publishing the plugin in SVN … same thing… too much for me.
But perhaps sharing what I’ll have could save others waisting their time on this.
I don’t make it sound like an exiting thing… But if one knows how to do an option page and an other how to publish the thing…
has anyone used this plugin ?
https://github.com/afragen/github-updater
it could simplify the mission
Hi, I see your plugin caches password protected posts except when password is not required (https://plugins.trac.www.ads-software.com/browser/cache-control/trunk/cache-control.php#L290). This cause password form to be cached and you can’t see protected content until cache expires.
I think you can remove the line linked before to solve the issue.
My workaround:
add_filter(‘cache_control_nocacheables’,function ($noncacheable){
global $post;
if(!empty($post->post_password) )
return true;
return $noncacheable;
});
Hi, the version specified on the plugin page says 2.2.4 and the version specified in the plugin (zip file as well as intallation) says 2.2.5. Not a big deal but might cause confusion.
]]>Hey, it seams I’m facing the same issue as others. I deactivated Cache Control to gain access to WP admin. Just wondering if a patched update version will be coming soon ?
Thanks
I can see in the last post that others have the same problem too. I just want to tell that several of our client websites crashed today after the update of your plugin today. We had a hard time to find out it was your plugin and removed it now manually. Big problem and hours of work to restore all websites. Great plugin but please test more carefully.
]]>The latest update (August 22nd) seems to jam access to wp-admin.
The front-end seems unaffected, but trying to get into the admin gives an error page “WordPress sent you an email” but no email is sent… so sorry, but I don’t have more info at this time.
As this happened on a buzzy website I just disabled the plugin to get things back working (varnish 2min default cache will do for the time being)
Let me know if you can’t reproduce the issue, I’ll then investigate further, but as wordpress intercepts the error and doesn’t forward it in my case it’ll be a bit tricky.
Wordpress Version 5.2.2
Logging in with administrator account
The Plugin “Cache-Control” has been removed from www.ads-software.com ans is no longer available for download.
Is this permanent or it just because a a security issue needing an update ??
This plugin is well handy and is the only one I could find that does the job (when behind varnish for example)
Thanks for your work and hope this isn’t the end of this.
]]>We are seeing 500s on some, but not all, permanent redirects in our production environment with the cache-control plugin enabled. Here’s what we see:
2018/12/07 17:22:29 [error] 18523#18523: *2917 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function get_queried_object_id() on null in WEBROOT/wp-includes/query.php:60
Stack trace:
#0 WEBROOT/wp-includes/class-wp-query.php(3989): get_queried_object_id()
#1 WEBROOT/wp-includes/class-wp-query.php(3100): WP_Query->setup_postdata(Object(WP_Post))
#2 WEBROOT/wp-content/plugins/cache-control/cache-control.php(185): WP_Query->the_post()
#3 WEBROOT/wp-content/plugins/cache-control/cache-control.php(244): cache_control_is_future_now_maxtime(86400)
#4 WEBROOT/wp-content/plugins/cache-control/cache-control.php(380): cache_control_build_directive_from_option('redirect_perman...')
#5 WEBROOT/wp-includes/class-wp-hook.php(286): cache_control_handle_redirects(301, 'https://www.was...')
#6 WEBROOT/wp-include" while reading response header from upstream, client: 127.0.0.1, server: HOSTNAME, request: "GET /PATH/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "HOSTNAME"
2018/12/07 17:22:46 [error] 18523#18523: *3297 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to a member function get_queried_object_id() on null in WEBROOT/wp-includes/query.php:60
Stack trace:
#0 WEBROOT/wp-includes/class-wp-query.php(3989): get_queried_object_id()
#1 WEBROOT/wp-includes/class-wp-query.php(3100): WP_Query->setup_postdata(Object(WP_Post))
#2 WEBROOT/wp-content/plugins/cache-control/cache-control.php(185): WP_Query->the_post()
#3 WEBROOT/wp-content/plugins/cache-control/cache-control.php(244): cache_control_is_future_now_maxtime(86400)
#4 WEBROOT/wp-content/plugins/cache-control/cache-control.php(380): cache_control_build_directive_from_option('redirect_perman...')
#5 WEBROOT/wp-includes/class-wp-hook.php(286): cache_control_handle_redirects(301, 'https://www.was...')
#6 WEBROOT/wp-include" while reading response header from upstream, client: 127.0.0.1, server: HOSTNAME, request: "GET /PATH/ HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.2-fpm.sock:", host: "HOSTNAME"
Haven’t validated this yet, but I wonder if adding redirect_permanent
to the list of option_names in #239-243 might help.
Hello.
Thank you for this simple yet great plugin. Are there any plans to add support for other directives defined in the specification? For example 5.2.2. Response Cache-Control Directives.
Thank you.
Hey Daniel,
I’ve noticed i have expiresbytype in my htaccess.
Do you recommend removing these when using cache control headers?
From what i understand cache control takes priority over expiresbytype, but i’m not sure if it’s safe to remove the latter as i still see a lot of sites using both.
Thanks!
]]>Ideally, any password protected ‘Post’ shouldn’t be cached at all.
It would be great, if you just mark it automatically as max-age=0
so frontend cache doesn’t affect the page for public users. I faced this problem, so thought to report.
We are behind cloudflare and have standard caching enabled. Our wordpress site uses page builders, and it’s quite a challenge for logged in users to correctly see changes as they do updates.
My question is, by what mechanism does this plugin prevent caching for logged in users?
Cloudflare states that if “MAX-AGE=0” is set, this will preggy much bypass caching. I am attempting to write a quick function that adds this cache-control header to pages for logged in users. But, I would rather use this plugin if I can achieve the same with it.
For logged in users, does it add max-age=0 to all pages? Can I somehow specify in the plugin settings that for logged in users I can require max-age=0?
Finally, we’re on a multisite network, and I would like this functionailty to be supported through out the family of sites. Will I have any issues in a multisite environment?
Thanks!
]]>I’m seeing the following warning message when using php 7.2:
Warning: Use of undefined constant last_com – assumed ‘last_com’ (this will throw an Error in a future version of PHP) in
/home/class211/public_html/wp-content/plugins/cache-control/cache-control.php on line 261
Looks like it should be $last_com on that line rather than last_com.
Hey !
This topic is the follow-up on https://www.ads-software.com/support/topic/document-has-moved-here-woocommerce-geolocate/#post-10094913
It seems that when I enable Cache-Control, and using WooCommerce with Geolocate with page caching enables (it adds a ?v parameter to the URL), my website is systematically throwing :
<!doctype html> <meta charset="utf-8"> <title>Document moved</title> <p>Document has <a href="https://wiseable.io/product/prince2-foundation-online-training/?v=7516fd43adaa">moved here</a>.</p>
<!-- Cache Enabler by KeyCDN @ 18.03.2018 16:08:46 (html) --><script type="text/javascript">
//<![CDATA[
window.__cfRocketOptions = {byc:0,p:1521385796,petok:"43e3d229a549058e553cdb5d884c3617c4d1e29e-1521385826-1800"};
//]]>
</script>
<script type="text/javascript" src="https://ajax.cloudflare.com/cdn-cgi/scripts/935cb224/cloudflare-static/rocket.min.js"></script>
Any idea from where it comes from ?
]]>Hi, Is it possible to set cache control for error pages such as 403, 500?
]]>Hi, Just out of interest, how do you apply the cache-control header to 404 pages? I’ve been struggling to figure this out using htaccess, which is normally quite easy for other file types and pages, but for the 404 i’m stumped. There doesn’t seem to be anything about this online either!
Thanks
]]>Hi —
I am working on a website my client has hosted on wordpress.com. I cannot directly access the .htaccess file to set expiration headers for resources that don’t change often. When I installed this plugin and set it up, it didn’t work. Is there a setting or something I missed, maybe a server option for Apache or Nginx? Or, does the plugin automatically check for the server type?
I would like to eliminate the browser caching issue to deliver a mid-90s pagespeed score to my client.
Thanks!
]]>Hi,
I really want to use this plugin with Cache Enabler but that plugin seems to strip these headers from the cached page.
Is it possible to get the two working together? Or would you perhaps know how to setup cache control headers for homepage, posts, category, in htaccess? That would be a great help if you can.
Thanks!
]]>Hi,
I can see the cache headers i set with the plugin when i don’t have my page cache plugin active. But once the page is cached the cache headers set by this plugin disappear. Do you know why this is happening?
]]>Hi, this looks like a great plugin. I wondering if you could clarify a few things for me?
1) This plugin tells my CDN how long to cache a page for? Is that correct? So if i have a page that never changes once published, i could set a long cache time such as 1 month?
2) What do you mean by the following at the bottom of your plugin options:
“You should also set Cache-Control headers manually in your webserver configuration for images, scripts, stylesheets, and other static resources.”
So if i create a page and it is cached by a caching plugin (e.g., WP Super Cache) will your plugin then not apply to all images, css, JS on that cached page?
Currently i have browser caching enabled in htaccess as follows:
## EXPIRES CACHING ##
<IfModule mod_expires.c>
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
ExpiresActive On
ExpiresDefault "access 1 month"
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType image/webp "access 1 year"
ExpiresByType image/ico "access 1 year"
ExpiresByType image/x-icon "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/javascript "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access 1 month"
ExpiresByType image/svg+xml "access plus 1 year"
</IfModule>
## EXPIRES CACHING ##
<IfModule mod_headers.c>
Header unset Pragma
Header unset ETag
FileETag None
Header set Connection keep-alive
</IfModule>
To set cache control header for images would i then need to add the following to my htaccess? Or does your plugin already take care of this if a page is cached by something like WP Super Cache?
# 1 MONTHS
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2419200, public"
ExpiresDefault "access plus 1 month"
SetOutputFilter DEFLATE
</FilesMatch>
Or is there no need to set the max-age directive with the cache-control header since it is already set by the mod_expires module for expires caching? As such:
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(css)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(js)$">
Header set Cache-Control "public"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header set Cache-Control "public"
</filesMatch>
</ifModule>
# END Cache-Control Headers
]]>
We ran in to an issue where the cache_control_is_future_now_maxtime
function was causing our homepage to generate Cache-Control: none
header because the WP_Query
call was returning stickied posts even though they have a post_status
of published
.
I applied the following patch which fixed our issue.
Index: cache-control.php
===================================================================
--- cache-control.php (revision 1691962)
+++ cache-control.php (working copy)
@@ -140,6 +140,7 @@
function cache_control_is_future_now_maxtime( $max_time_future ) {
// trusting the database to cache this query
$future_post = new WP_Query( array( 'post_status' => 'future',
+ 'ignore_sticky_posts' => true,
'posts_per_page' => 1,
'orderby' => 'date',
'order' => 'ASC'
]]>
The plugin seem to cache “Password Protected Posts”.
Therefore a password-protected post returns
both a password form and a post whether cached or not.
I think the plugin should check $post->post_password
in cache_control_nocacheables
function,
and do not cache if true.
function cache_control_nocacheables() {
global $post;
$noncacheable = ( is_preview() ||
is_user_logged_in() ||
is_trackback() ||
is_admin() ||
$post->post_password );
Thank you for reading.
]]>