latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Cannot Get Quick Cache to Work-No Mutex Lock

Home Forums Community Forum Cannot Get Quick Cache to Work-No Mutex Lock

This topic contains 16 replies, has 4 voices. Last updated by  Jason (Lead Developer) 3 years, 10 months ago.

Topic Author Topic
Posted: Tuesday Feb 12th, 2013 at 1:00 am #41528
carolm
Username: carolm

I’ve Checked everything 3 times. When I log out and look at my view Page Source there is no green Quick Cache information at the end of the page.

I checked wp-content/cache/advanced cache (I think) – and I found this about Quick Cache (an extract):

if (QUICK_CACHE_USE_FLOCK_OR_SEM === “sem” && function_exists (“sem_get”) && ($mutex = @sem_get (1976, 1, 0644 | IPC_CREAT, 1)) && @sem_acquire ($mutex) && ($cached = true))
file_put_contents (QUICK_CACHE_FILE, serialize ($headers) . “” . $cache) . sem_release ($mutex);
/**/
else if (($mutex = @fopen (WP_CONTENT_DIR . “/cache/qc-l-mutex.lock”, “w”)) && @flock ($mutex, LOCK_EX) && ($cached = true))
file_put_contents (QUICK_CACHE_FILE, serialize ($headers) . “” . $cache) . flock ($mutex, LOCK_UN);
/**/
return ($cached) ? $cache : $buffer . “n“;
}
else /* We need to report that the cache/ directory is either non-existent ( and could not be created ) or it is not writable. */
{
return $buffer . “n“;
}
}
/**/
ob_start(“ws_plugin__qcache_builder”); /* Start output buffering. */
}
}
}
}
/**/
if (QUICK_CACHE_ENABLED) /* Only if enabled. */
call_user_func(“ws_plugin__qcache_handler”);

I’m not geek enough to know what this means. But I can see it’s to do with not finding a Mutex Lock, whatever that is.

I’ve tried Mutex Flock and Semaphore in settings but still no green text showing.

When I publish something, there is a message that Quick Cache has updated, and yet still no green text when logged out.

I installed Quick Cache on both my sites and the same problem with both of them. The theme is Weaver which is compatible, and I have S2member plugin which works well.

The website is http://www.mysecondmillion.com.

I’ve written a rave article saying how easy it is to install Quick Cache and how brilliant it is….and yet, it’s not working for me – don’t tell my readers! At least not until I can get it working.

Interestingly my website is faster since installing Quick Cache, and yet I see no evidence of it working.

Can someone please help – I’m feeling like a bit like a fraud, so i have to get it fixed before any of my readers notice.

List Of Topic Replies

Viewing 16 replies - 1 through 16 (of 16 total)
Author Replies
Author Replies
Posted: Thursday Feb 14th, 2013 at 7:23 pm #41729
Eduan
Username: Eduan
Moderator

Hello carolm,

I’m not sure of what the problem is. Is Quick Cache working for you or not? To what green text are you referring?

Pretty sure Quick Cache doesn’t output anything to the user, only to the admin.

– Eduan

Posted: Friday Feb 15th, 2013 at 8:02 am #41866
carolm
Username: carolm

Hi Eduan, you are supposed to know that the Quick Cache is working by logging out and looking at the HTML version of a page.

You are supposed to see green text at the end of the HTML Code that gives you data about what Quick Cache is doing and how it is working properly. And I don’t have it there.

Also, that extract from my wp-content/cache/advanced cache actually says that it isn’t working because something called a Mutex Lock couldn’t be found.

Also if I test my site with online website checkers, they say that my website has no cache.

I’m stumped because I did everything as I’m supposed to, and yet, the cache is not working.

Posted: Saturday Feb 16th, 2013 at 3:44 pm #41964
Eduan
Username: Eduan
Moderator

Hmm… Well I’m not sure what the problem may be. Honestly I’m quite new to Quick Cache since I don’t use caching plugins.

I asked Jason for his opinion, maybe he has a solution. :)

Meanwhile, did you try these common trouble shooting tips: Knowledge Base » Common Troubleshooting Tips

Most of them apply to any situation, not only if you’re using s2Member. :)

– Eduan

Posted: Saturday Feb 16th, 2013 at 6:34 pm #42001
carolm
Username: carolm

Thanks for the reply Eduan.

Those trouble shooting tips from the Knowledge Base relate to the S2member plugin. And I’m happy to report that the S2member plugin works brilliantly on my site. I wrote a rave review about that plugin too, including a ‘How To’ on the MailChimp integration.

I will be interested to know if Jason has any ideas on my Quick Cache problem – I haven’t been able to find any threads here that mention problems with Mutex locks.

If I can get this fixed, I will be amending my Review of Quick Cache to include a ‘How To’ about how it was fixed.

Posted: Saturday Feb 16th, 2013 at 6:42 pm #42004
Eduan
Username: Eduan
Moderator

Cool. :)
I already contacted Jason about this. So it’s just waiting for his answer. :)

Posted: Sunday Feb 17th, 2013 at 6:22 pm #42218
Staff Member

Thanks for the heads up on this thread :-)

It sounds like you’ve had some corruption somewhere, or possibly changed permissions on files in the cache directory by mistake at some point. To verify this, please check this directory on your installation.

See: /wp-content/cache/
Please delete ALL files in that directory (including any lock files).

Now be sure that your /wp-content/cache/ directory is empty and that it has permissions set to 755 or higher.

Please let us know if problems persist :-)

Posted: Sunday Feb 17th, 2013 at 11:36 pm #42229
carolm
Username: carolm

Thanks Jason, I’ll have a look at those files, but I will get my host to follow your instructions – I don’t want to mess with stuff I don’t understand.

For example: what is a Permission? You don’t have to answer that, but it shows you how helpless non-geeks are when something goes wrong! We never understand the answers – well, almost never.

I’ll get my Host people to do what you advise.

And I will let you know what happens.

Thanks for your help!

Posted: Sunday Feb 17th, 2013 at 11:51 pm #42230
carolm
Username: carolm

Ha! I see what Permissions are! But I’m still going to get my Host to do the deed.

Posted: Tuesday Feb 19th, 2013 at 2:05 am #42436
carolm
Username: carolm

I deleted all the entries in wp-content/cache, except there was one there for my WPStats Dashboard plugin.

I didn’t want to delete that because it is useful and links in with the Jetpack plugin which is also useful.

I didn’t uninstall the Quick Cache before clearing the cache, and it immediately started to be repopulated with files from QC. But the Mutex Lock file still shows Zero KB. And still no green text in the logged out Page Source HTML.

Would it help if I disabled the QC plugin, cleared the cache again (but leaving the WPStatsDashboard file – it contains 2 files of letters and numbers) and re-installed Quick Cache?

Or do you think it’s the WPStatsDashboard file that is preventing the QC plugin from working?

I also checked the Permissions: they were set to
Read: everything.
Write: user only.
Execute: nil.
I changed them all (User, Group and World) to full read write and execute but it didn’t help.

Any advice?

Posted: Tuesday Feb 19th, 2013 at 4:46 am #42461
carolm
Username: carolm

Update:

I disabled and deleted the WPStatsDashboard, disabled the Quick Cache, totally deleted everything in the wp-content/cache, changed all the permissions to read, write and execute.

Made Permissions 0777. Enabled Quick Cache again. Refreshed cpanel – Mutex Lock still Zero KBs. Logged out of site, still no green text.

So, it’s not a clash with the WPStatsDashboard plugin.

The problem is still that I don’t have a Mutex Lock of any sort. Any ideas why, or how I can fix it?

Posted: Thursday Feb 21st, 2013 at 10:53 pm #42778
Istvan Magyar
Username: istvan

Hi,

I have the same problem.

The line at the end of the html script is:

‘Quick Cache: failed to write cache, unable to obtain a mutex lock at the moment. Quick Cache will try again later.’

Details I can read from header: ‘Cache-Control: no-cache, no-store, max-age=0, must-revalidate’

I have checked the /wp-content/cache/ directory. Permission is 755. There was a file called qc-l-mutex.lock. It was completely blank, no text. I deleted the file, it keeps coming back, still blank.

I changed the mutex file locking settings to ‘Flock’, same error.

I cleared plugin cache, cleared browser cache, no change.

I tried if the problem disappears with all plugins deactivated, it didn’t, still got the same error message. I deactivated-uninstalled-reinstalled the plugin, no luck.

Please advise us, thanks,

Istvan

Posted: Monday Feb 25th, 2013 at 2:38 pm #43178
Istvan Magyar
Username: istvan

Hello?
Any support for this plugin?

Posted: Tuesday Feb 26th, 2013 at 1:45 am #43200
Staff Member

Thanks for the follow-ups :-)

If this file exists: /wp-content/cache/qc-l-mutex.lock, it means that Quick Cache was either configured to use the FLOCK method for file locks; or the Semaphore method was not possible on your hosting platform; so Quick Cache is reverting the the FLOCK method as a good backup choice.

It is normal for this file to be 0 kbs: /wp-content/cache/qc-l-mutex.lock
This file exists simply as a locking mechanism (i.e. it simply needs to exist); so that Quick Cache can obtain an exclusive lock over files in this directory while it’s writing cache entries.

If you receive this error in Quick Cache comments:

Quick Cache: failed to write cache, unable to obtain a mutex lock at the moment. Quick Cache will try again later.

Here are the steps to resolve the issue.

1. Delete the existing file: /wp-content/cache/qc-l-mutex.lock
This will release any existing locks on that file, making it possible for Quick Cache to recreate the file and obtain an exclusive lock on this file once again; as it needs to.

Why would Quick Cache lose the ability to obtain an exclusive lock on this file?
It’s very uncommon for this to occur, but we have seen it happen on sites that move or change directory permissions on the /wp-content/cache/ directory; or on sites that are struggling to keep up with traffic volume; where Apache or PHP is crashing or being restarted periodically.

2. Check directory permissions on the /wp-content/cache/ directory. You need 755 or higher. Whatever is necessary for Quick Cache to have write-access to that directory. If 755 does not do it (755 does the trick on most hosting platforms); but if it does not, you may have to go all the way up to 777 with your permissions.

3. If the error continues to come back periodically, it could indicate a slow disk on the underlying server that is hosting your site (i.e. disk writes are not occurring fast enough to keep up with your traffic volume). Raising your Cache Expiration Time in the Quick Cache configuration panel can help to resolve this, because that results in fewer cache files being written by Quick Cache.

So what is the purpose of a Mutex Lock File exactly?

If two or more visitors hit the same page at the same time, and Quick Cache needs to cache (or re-cache) that page as it’s being served, only one of these visitors will trigger the cache writing routine. This is where a Mutex Lock comes in. Only one of these visitors (i.e. instances of Quick Cache) will obtain a Mutex Lock; and thus only one instance of Quick Cache creates (or recreates) the cache file for that page. The other one fails to obtain an exclusive lock; because another cache file is being written from another page view (e.g. from another instance of Quick Cache). Which is good, only one cache file should be written at a time.

This ensures that Quick Cache is only writing one new cache file at a time; and never attempting to write multiple simultaneous cache entries on a single installation. Seeing Mutex Lock notices in Quick Cache comments periodically is normal. Seeing them all the time is not. If you are seeing them all the time, it indicates a problem.


I have checked the /wp-content/cache/ directory. Permission is 755. There was a file called qc-l-mutex.lock. It was completely blank, no text. I deleted the file, it keeps coming back, still blank.

It is normal for this file to keep coming back, and it is normal for this file to be 0 kbs.

What if this file does NOT exist at all?
/wp-content/cache/qc-l-mutex.lock

That would indicate that caching is either not enabled on your installation, or that you’ve selected the Semaphore method for your Mutex Locks (see: Quick Cache Options -> Mutex File Locking). With the Semaphore method (if that’s possible on your server), Quick Cache maintains a lock through a Semaphore on the server, and this lock file is not necessary. See: http://php.net/manual/en/function.sem-get.php

The Semaphore method is recommended for extremely high traffic sites (if possible). If you configure Quick Cache to use the Semaphore method, but this file is created automatically by Quick Cache: /wp-content/cache/qc-l-mutex.lock, it means the Semaphore method is not possible in your current hosting platform; so Quick Cache is reverting to the FLOCK method automatically. See: http://php.net/manual/en/function.flock.php

Posted: Tuesday Feb 26th, 2013 at 1:40 pm #43254
Istvan Magyar
Username: istvan

Hi Jason,

Thank you for the detailed explanation.

1. I have checked the mutex lock settings. The lock file does exist in both Semaphore and Flock settings, I guess that means that it reverts to Flock for some reason. (which in itself would be fine if I understand what you are saying).

2. I have set the folder permission to 755 and then to 777. Still no cache file written due to the same error.

3. the traffic on my site is extremely low. how heavy it is on the server I am not sure as it is a cloud hosting package. But on my site itself, a dozen visitors a day. Cache expiration time is set to 604800 seconds, I don’t think that needs to be more does it?

4. “Seeing Mutex Lock notices in Quick Cache comments periodically is normal. Seeing them all the time is not. If you are seeing them all the time, it indicates a problem.”

Well, I see the comment all the time. It is always there regardless to the above settings.

Now what do I do? :)

Posted: Saturday Mar 2nd, 2013 at 2:35 pm #43630
Staff Member

Thanks for the follow-up :-)

I would suggest that you contact your hosting company and ask them to investigate this for you. It sounds there could be an incompatibility in the Apache configuration of some kind. An email to hosting support about Quick Cache compatibility may help. I would ask them specifically why PHP scripts would be unable to write to a .lock file. Another thing you can try is to open this file:
/wp-content/plugins/quick-cache/includes/templates/handler.tpl.php

At line #252 find these two PHP calls where you see the @ sign. Remove the @ sign to unsuppress server error notices; and this may result in an error message on-site that could give you some direction on where to go next.

$mutex = @fopen (WP_CONTENT_DIR . "/cache/qc-l-mutex.lock", "w"))
@flock ($mutex, LOCK_EX);

After removing the @ signs, visit your Dashboard and disable (then re-enable) Quick Cache.

Monitor your PHP and Apache error logs now. Anything useful there?

Posted: Saturday Mar 2nd, 2013 at 2:50 pm #43632
Staff Member

If you are on a Cloud computing model, I would check with your hosting company about the /wp-content/cache/ directory. Ask them if this directory is being served from a CDN; or from local file storage; or from a network file storage? Ask them why PHP scripts would have trouble reading/writing (and locking) files in that directory.

Viewing 16 replies - 1 through 16 (of 16 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.