I'm running a CodeIgniter site and using CI's caching tools. On several pages, I decided to remove a bunch of images (they were CSS-sprited but still over 300K in size) and let the user decide if they wanted to show them.
Then I thought it would be neat to allow the user to keep images displayed across the various pages to avoid repeated clicking of "display images" (and especially since the images would be cached in their browser once loaded).
I'm using a cookie to store the user preference, but this means I c开发者_运维知识库an't serve a cached version of the page because it will be different for half the visitors. Can I cache two versions of the file, and serve a different one based if the cookie is present?
EDIT: should also add that I am currently using a Javascript solution that checks for the cookie via JS and loads images thusly. This kinda feels like a hack and seems a little slow, so I was hoping for a server-side solution if possible.
By default, No.
CodeIgniter looks for a page with a name of the hashed filename+plus other stuff. You'd need to have another URL for another cached page.
精彩评论