-
-
Notifications
You must be signed in to change notification settings - Fork 606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fastcgi caching #234
Fastcgi caching #234
Conversation
set $skip_cache 0; | ||
|
||
# POST requests and urls with a query string should always go to PHP | ||
if ($request_method = POST) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think your logic is backwards. The caching methods should be a whitelist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other words: you should only be caching GET calls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@austinpray You are totally right, in fact it is not even used as Nginx default cached method are only GET and HEAD. http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_cache_methods
I updated accordingly.
@louim thanks for this. It's looking mostly good. For your questions:
|
@swalkinshaw thanks for the comments, I updated the PR to fix what you mentioned. Just to follow up on you answers:
|
|
@swalkinshaw I made the config site specific. It required me to move the Settings can be used like : ...
ssl:
enabled: false
cache:
enabled: true
duration: 30s
skip_cache_uri: "some string here"
skip_cache_cookie: "some other string here"
system_cron: true
... All params will take the default global value when not specifically defined in a site. I also added Just let me know if everything looks good to you, and Ill write the documentation and squash my commits. As a side note, If we one day decide to compile NGINX from source (saw that mentioned in #235), it would be interesting to compile it with https://github.com/FRiCKLE/ngx_cache_purge, so the setup can be used with longer cache time. This would allow people to use plugin like https://wordpress.org/plugins/nginx-helper/ to purge their cache from the wordpress admin. |
@louim this looks great. Want to squash and update readme/wiki? |
@swalkinshaw I'm unable to edit / create new page to the wiki. Would you mind opening the wiki for public edit or adding me as a collaborator so I can edit it? |
@louim it's public now |
Make fastcgi_cache a template, since we have variables in it. Correct indentation and add default parameter that can be overridden
@swalkinshaw Updated the wiki and the readme, rebased against the current master. Should be good to go! 👍 |
Tested this out and it's working great. Thanks @louim |
Hello, as mentioned in #186 this is a "microcaching" setup we have used in the past with Bedrock.
I have a couple of question about where should I go from now.
/var/run
since it is in memory instead of being on the filesystem. However I decided to scrap the idea, because it would require changing the Nginx init script to create the folder after each server reboot, since/var/run
is cleared. What do you think?Comments are welcome.
I will be following shortly with another pull request that aim to prevent website DDOS using 404s. That was one of the weak point we saw when using the cache.