reed Posted October 4, 2021 Share Posted October 4, 2021 Hey y'all! It's been a while since I jumped into the forums, so I'm hoping this is in the right place. So — I'm using Pro Cache to deliver cached versions of my site pages. It's the absolute best. But I recently added a dark-mode to my site, which first checks for a cookie to set a global <body> class based on the visitor's established preference, and falls back to the user's system-level color scheme with the media query: @media (prefers-color-scheme: dark) The problem is, cached pages seem to adopt the mode of the user who first visited the page and triggered the cache? I'm still messing around with it, but if anyone has ideas for how to both cache pages, and deliver each user content in the mode they prefer let me know. Thanks so much! 1 Link to comment Share on other sites More sharing options...
horst Posted October 4, 2021 Share Posted October 4, 2021 I do such things with a small javascript or AJAX call on doc ready or similar. Or sometimes in the head section of the HTML page, depending what is needed. So you may add a small JS snippet directly after the opening body tag that checks the user preferences and according the result, add or remove a css class from/to body. (?) 1 Link to comment Share on other sites More sharing options...
reed Posted October 4, 2021 Author Share Posted October 4, 2021 Thanks so much horst! That makes a ton of sense — I'll get into it and post when I've got a solve. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now