Besides serving static files directly, does mechanic expose any commands/tools for adding in caching in nginx? Additionally, are there any gotchas with using nginx's built-in caching with Apostrophe or specific configurations I should use to make sure I'm not borking up core functionality?
1 Answers
I'm the lead architect of Apostrophe at P'unk Avenue.
Mechanic doesn't specifically expose any caching options. You should be able to set up caching via the /etc/nginx/mechanic-overrides
folder though, which provides places to insert custom rules at various points in the nginx configuration file that mechanic builds.
As for Apostrophe, there is definitely an issue for administrators editing the site. If you cache the pages, then logging in won't change the appearance of the site to include editing controls. If you make an edit and the edit is cached, you won't see your work. This kind of thing would lead to inconsistent and confusing behavior.
So what I would recommend is using mechanic to set up a separate subdomain of your site just for editing purposes, pointing to the same backend port. The only difference will be that you will not enable caching for it.
This works well but you do have to be careful not to paste any absolute links to the editing subdomain when editing links with the rich text editor.
Then you can cache to your heart's content for the primary domain, as long as you are comfortable with the caching rules you're setting.
Naturally, if you cache the home page for up to a day and then edit the home page, that change will not be immediately reflected on the primary domain.
However, also keep in mind that mechanic is already set up to deliver static files such as media and CSS/JS/font assets directly via nginx, bypassing the backend node process for these. So it's really only necessary to consider caching at the nginx level if you are concerned about the performance of the pages themselves under heavy load.
Speaking of which, you should definitely be running Apostrophe in our multicore configuration, to improve both scalability and reliability:
Running Apostrophe on multiple cores and/or servers
Hope this is helpful!

- 7,281
- 1
- 26
- 23
-
Thanks! Very helpful. – dgwebb May 30 '17 at 15:14