Closed chrisbataille closed 9 years ago
The reason is simple: both directories contain different content.
/wp-content/cache/min/
contains all the minimized and concatenated files (CSS, JS) "compiled" by WP-Rocket. Therefore, for example, style.css
and plugin_style.css
will be minimized and concatenated in a new file f4e8a8be0c931.css
. In your HTML, you will see this newly generated file that contains CSS or JS (depending on the case) and, as it's not PHP, it does not need a @fallback
.
/wp-content/cache/wp-rocket
will contain HTML files generated from your PHP scripts (plugins, themes and WordPress itself). If the HTML file exists, it is served. Otherwise, the file needs to be generated and that is why the fallback exists.
I hope it now makes sense for you! :-)
well i do understand my part.
But still in your conf i don't understand how nginx ever come to call the /wp-content/cache/wp-rocket/.* as it never shows up in any html content
On line 45, you have this line:
set $rocket_url "/wp-content/cache/wp-rocket/$http_host/$request_uri/index$https_prefix.html$rocket_encryption";
This line identifies what is the file name where the cached HTML should be found. Then, later in the configuration, we check if the file exists. If it exists, we tell NGINX to serve that file by rewriting the original request to use the specific file:
# If the bypass token is still on, rewrite according to the file linked to the request
if ($rocket_bypass = 1) {
rewrite .* "$rocket_url" last;
}
Let's say the file does not exist. This mean that there is no cached file. In that case, it is the default WordPress behaviour.
In short, the pseudo-code is:
if a cache file exists
serve that file
else
Business as usual (aka WordPress handles the request as if our configuration did not exist).
rewrite .* "$rocket_url" last;
was the part i had overlooked. Thanks this now all makes sense to me and i can now safely use it on my server.
Thanks again for your support and patience with a newbie like me.
Have a good day.
No problem. :-)
Hi, I just found this googling and trying to understand better how it works. Or maybe a comment on the code on that line. I was looking too for a "try_files" directive somewhere. This should be on the readme or on a doc somewhere. :) Thanks for the great code! 👍
Hello, thanks for your conf this did help me in setting up mine ... though i have a couple of questions :
. your locations are matching /wp-content/cache/wp-rocket/.* but if i understand correctly these location should never be hit by nginx as a html would contain userfriendly urls (/tag/somegoodpost, or / or anything else but never /wp-content/) Maybe my understanding of nginx is poor and that is a stupid question .. but anyhow i hope you can help.
On my side i have something like this :
location ~ ^/wp-content/cache/min/ { try_files $uri @fallback; } (to hit minified css and js) AND location / { try_files /wp-content/cache/wp-rocket/$http_host/$cache_uri/index.html @fallback; }
with @fallback being the php-fpm call when the file has not been cached yet
It's very different that what i could see in your script and can't figure out why.