I have a WordPress site (2 load balanced with a separate shared db server actually), and I have a growing number of users that login to get access to certain content areas of the site. Since the content (although not the access) is static, I would like to cache these pages for logged in users but I have the following problem:
Each of these pages contain links to internal resources that are controlled depending on the membership rights the user has. So for example, on a page of links some of the links will go to the content (if one has rights) and some will go to a “please subscribe for access” page.
I am researching the best way to cache these pages, here are some ideas:
Set cookies based on rights, and cache the output of each page result that matches every combo of cookies
Any other suggestions? Is there some better system out there for caching only parts of a page or fragment? Or something that caches every possibility but only serves the appropriate cached version based on user rights?
Thanks in advance for any suggestions or pointers!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
I answered my own question (or at least have one answer). Here is what I am doing in case it helps anyone else:
Now, those pages are cached, and will show to the appropriate user based on their membership combination. So I get the benefit of fast cached pages while still respecting user rights.
Can you share the function that sets the cookie upon login?
Want to learn more? Join the DigitalOcean Community!
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Sign up now