This page lists various w3 total cache settings to be used in various scenarios.
I will keep adding more settings to it so that you can benefit. You can also add settings via comments or suggest any edits / modifications.
WooCommerce & W3 Total Cache
We need to add these settings for w3 total cache for woocommerce.
- Add “mfunc” to ignored comment stem in minify
- Add “_wc_session_” in ignored query stems on Database cache page
- Make sure page cache is disabled for logged in users
Common Errors with W3 Total Cache and their solutions
These are commonly encountered errors with w3 Total Cache and how to solve them.
A. Minify not working:
If everything works fine but minify isn’t working, follow these steps:
- Make sure that the wp-content directory contains these folders (if not then simply create them with 755 permissions)
- cache
- w3tc
- w3tc-config
- Make sure that there is no empty space after the closing tag ?> in functions.php of your theme – especially if url rewriting not working for your theme
- On nginx – make sure the path of correct nginx.conf file is mentioned in w3 total cache general settings page (and has correct permissions too)
- Check the owner (chown) for your websites directory and all files and folders in it
- If still doesn’t work, try disabling Rewrite URL structure by unchecking it. Confirm that everything works now and then re-enable the rewrite url structure.
- Check Disable minify automatic file name length test and give a manual value, starting from 60 and then going up gradually till it’s supported, clear cache each time you change it and check in incognito mode (or a different browser where you’re not logged in)
- Go to the install tab and follow the steps
- At least follow the permissions and .htaccess edits steps
- If you own the server or are using a vps, get the other steps done too, only if you understand what they are, as not all need to be done and some might conflict with each other imho (needs citation)
B. Fonts (or font-awesome) not working through cdn
Cross domain inclusion of fonts isn’t allowed allowed by CORS policy. This results in issue usually when using the fonts through cdn by uploading them along with media and other files, like with amazon cloudfront, maxcdn, etc.
For fonts to work properly, follow these steps:
- Allow cross domain including of fonts through .htaccess before enabling the cdn for the first time
- If you’ve already used the cdn and fonts are giving error, enable the cross domain usage and then purge the font files from cdn, if not possible then rename the font file
Enable cross domain including of fonts (or any other file) by using (select the one you need, based on your server, if it’s apache or nginx:
# Apache config
<FilesMatch ".(eot|ttf|otf|woff)">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>
# nginx config
if ($filename ~* ^.*?\.(eot)|(ttf)|(woff)$){
add_header Access-Control-Allow-Origin *;
}
Note that the nginx conf might be required to be added inside location directive depending upon server nginx.conf configuration.
Changes not visible after making change
Make sure you:
- Clear All cache
- Purge the changed file (or all files) from cdn if it’s enabled and the filenames didn’t change after making the changes
If you still have any difficulty while configuring w3 total cache or any other stuff related to WordPress or pagespeed optimization, do let me know!
Moving W3 Total Cache JS to footer
Use this code before the closing tag </body> to move the minified javascript to this location. Please use it carefully and confirm that moving the js files don’t break any script or functionality on your page.
<!-- W3TC-include-js-head -->
Move W3 Total Cache CSS to footer
Use this tag above wp_footer(); call in footer.php to output the minified css to that location instead of head.
<!-- W3TC-include-css -->
Note that this probably works in manual minify only, as I wasn’t able to get it done on auto mode minify site (please confirm).
Nginx.conf Changes not reflecting on nginx server
Make sure that the nginx.conf file in website root directory is included in the server nginx.conf file for the current domain.
Add it like this in server directive:
include /var/www/html/path/to/domain/public_html/nginx.conf
You will have to restart nginx after this and every time you make changes to nginx.conf file too.