Berto
Berto

Reputation: 722

WordPress W3 Total Cache Minify - JS and CSS Files Not Created (nginx)

I have a WordPress site I'm trying to minify with W3 Total Cache. It runs on nginx on Ubuntu 12.04.

When I load the site, it tells WP to load from the following path:

/wp-content/plugins/w3-total-cache/pub/minify.php?file=5fe99/default.include-body.baf22c.js

Likewise, had I turned Rewrite URL structure ON, that path would be: /wp-content/cache/minify/000000/5fe99/default.include-body.baf22c.js

That file does not exist and it 404's if you try to go to it.

Looking at that directory, I have:

~/public_html/wp-content/cache/minify/000000/5fe99$ ls -lah drwxrwxrwx 2 www-data www-data 4.0K Jun 26 08:51 . drwxrwxrwx 3 www-data www-data 4.0K Jun 26 08:51 .. -rw-r--r-- 1 www-data www-data 13 Jun 26 08:51 default.include-body.js.id -rwxrwxrwx 1 www-data www-data 13 Jun 26 08:23 default.include.css.id.old

Other potential solutions:

Contents of local nginx.conf file:

When Rewrite URL structure is OFF, this is all that is requested:

# BEGIN W3TC Minify cache location ~ /home/MY_HOME_DIR/public_html/wp-content/cache/minify.*\.js$ { types {} default_type application/x-javascript; expires modified 31536000s; add_header Vary "Accept-Encoding"; add_header Pragma "public"; add_header Cache-Control "max-age=31536000, public"; } location ~ /home/MY_HOME_DIR/public_html/wp-content/cache/minify.*\.css$ { types {} default_type text/css; expires modified 31536000s; add_header Vary "Accept-Encoding"; add_header Pragma "public"; add_header Cache-Control "max-age=31536000, public"; } location ~ /home/MY_HOME_DIR/public_html/wp-content/cache/minify.*js\.gzip$ { gzip off; types {} default_type application/x-javascript; expires modified 31536000s; add_header Vary "Accept-Encoding"; add_header Pragma "public"; add_header Cache-Control "max-age=31536000, public"; add_header Content-Encoding gzip; } location ~ /home/MY_HOME_DIR/public_html/wp-content/cache/minify.*css\.gzip$ { gzip off; types {} default_type text/css; expires modified 31536000s; add_header Vary "Accept-Encoding"; add_header Pragma "public"; add_header Cache-Control "max-age=31536000, public"; add_header Content-Encoding gzip; } # END W3TC Minify cache

Another error:

Meanwhile, I also get this error:

Recently an error occurred while creating the CSS / JS minify cache: A group configuration for "include-body" was not set.

The plugin author has reported this as a frequent false positive, but that was two years ago. I'm not sure what that means, there's not much good information on it.

So... has anyone ever gotten file minification to work with W3 Total Cache on nginx? Thanks!

Upvotes: 5

Views: 11940

Answers (1)

Dario Fumagalli
Dario Fumagalli

Reputation: 1264

I have partly fixed the issue by making sure that:

1) The nginx.conf file was updated to the last options choices.

This means, every time one changes minification options, he has to go to

http://www.domain.tld/wp-admin/admin.php?page=w3tc_install

and copy the nginx sample config and overwrite the current nginx.conf

2) Nginx new config is reloaded or Nginx is restarted:

nginx -s reload

or

service nginx restart

3) Uncheck the "Rewrite URL structure" option in the W3TC Minify page.

This is going to make generated pages a tiny bit less performing but I have not found a real workaround that works on all my websites.

Upvotes: 5

Related Questions