Wp-cron.php getting cached even though I tried not to (fastcgicache)

This is my nginx snippet and wp-cron should NOt be cached, is there an error somewhere in here?

#activating fastcgi_cache  
set $skip_cache 0;  

# POST requests and urls with a query string should always go to PHP  
if ($request_method = POST) { set $skip_cache 1; }   
if ($query_string != "") { set $skip_cache 1; }   

#Skip cache for WooCommerce query string  
if ( $arg_add-to-cart != "" ) { set $skip_cache 1; }  

#Skip cache when WooCommerce cart is not empty  
if ( $cookie_woocommerce_items_in_cart != "0" ) { set $skip_cache 1; }  

# Don't use the cache for logged in users or recent commenters  
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|piwik_auth") { set $skip_cache 1; }  

# Don't cache uris containing the following segments  
if ($request_uri ~* ("/wp-admin.*|/cart.*|/checkout.*|/account.*|/myaccount.*|/addond.*|/store.*|/shop.*|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-ocations.php|sitemap(_index)?.xml|a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $skip_cache 1; }   

location ~ /purge(/.*) { fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1"; }

Please ignore/delete.
I’m too tired.
Saw caching happening where it was not.

Checked again: http://foodandchatter.co.za/wp-cron.php and the nginx helper time stamp seems to change so its not cached.

But now I am wondering about something else:

how come when I’m logged in I see the nginx helper time stamp but when I’m not logged in I only see: “Connection closed”?

Does my cron job as described here: http://rtcamp.com/wordpress-nginx/tutorials/plugins/wp-cron-crontab/ still work?

@ovidiu

May I know what problem we are trying to solve? cache or connection-closed?

For cache-checks… as you are using fastcgi-cache use this method to check if cache is working properly http://rtcamp.com/tutorials/nginx/upstream-cache-status-in-response-header/

For connection close, you should see something in nginx error log.

Hi Rahul,

what I’m trying to determine is this:

Does my cron job as described here: http://rtcamp.com/wordpress-nginx/tutorials/plugins/wp-cron-crontab/ still work?

I checked what you advised and the result says:

Fastcgi-Cache: HIT

So I think my replacement of wp-cron with a real cron job does not work since it gets a cached hit. And looking at the info I gave above, why is it caching wp-cron.php?

I am not sure you are getting cache hits.

We have same config on this server.

For:

curl http://rtcamp.com/wp-cron.php -X GET -I

You can see:

rt-Fastcgi-Cache: BYPASS

in output.

hm, do you see an error or a typo somewhere here? https://rtcamp.com/support/topic/wp-cron-php-getting-cached-even-though-i-tried-not-to-fastcgicache/#post-49567

Otherwise why would I get a HIT?

Can you send complete config? May be using https://gist.github.com/ or any other pasting service?

this was a private reply with post_id 49840

@ovidiu

Looks like you are using ISPConfig on this server.

Sorry but since https://github.com/rtCamp/easyengine is out, we stopped giving support for ISPConfig. We only only support configs that are following our tutorials throughout or created using easyengine.

I understand, but can you please just look at the line with wp-cron.php and let me know if you can spot an error?

I think you need to check error log. In your case it’s returning
“Connection closed” response which is wrong.

wp-cron.php doesn’t return output as far as I know.

That is really weird.

If I try http://foodandchatter.co.za/wp-cron.php in my browser and am not logged in it does indeed say connection closed.

If I try curl http://foodandchatter.co.za/wp-cron.php -X GET -I I get: Fastcgi-Cache: HIT

If I try: curl http://rtcamp.com/wp-cron.php -X GET -I I don’t see anything fastcgi related.

Very weird, my error log does only show this error, a few times but a few hours before so even though I got the ‘connection close’ message in my browser a few times during the last few minutes, the error log only shows these errors from a few hours ago.

013/11/03 10:55:01 [error] 49683#0: *1294898 FastCGI sent in stderr: “PHP message: WordPress database error MySQL server has gone away for query SELECT option_value FROM wp_options WHERE option_name = ‘_transient_doing_cron’ LIMIT 1 made by _get_cron_lock”, client: 85.214.221.98, server: foodandchatter.co.za, request: “GET /wp-cron.php HTTP/1.1”, host: “foodandchatter.co.za”

Any other ideas?

Try increasing mysql wait_timeout and max_connections.

Looks like your cron is taking longer than mysql wait_timeout.

sorry, my mistake, still investigating this issue

On a hunch, can you say if there is anything wrong with these proxy parameters?

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

That is the only thing that looks suspicious right now :frowning: