Jump to content

Double cache


Frank Vèssia
 Share

Recommended Posts

Hi guys,
I have a photo website, where a photo page (containing an image field) is showing a pixelate version for not loggedin users and the regular photo for loggedin users.
There is a way to cache this content twice and show it to the right users? Or show the cached content only for loggedin or not loggedin users? Because right now if I use the regular template cache it happens for example that a loggedin user sees the pixelate version, probably cached by a not loggedin user which visited the page before him and viceversa.

Link to comment
Share on other sites

Chaching and personalized pages are not the best friends. I'm not really sure where are the differences with this caching methods, but I think there is no way around some clientside action (JS! + ajax?).

What comes into my mind is: does you serve the complete page from cache, like with ProCache? Or do you serve a little part with uncached output?

If the latter one, you may store a JS-var that flags if a user is loggedin, and regardless if in the cached or uncached part a JS function that do a ajax call only if the user is logged in to fetch unpixelated content.

Link to comment
Share on other sites

You could redirect the images to a php file that decides which version to serve. That way you can serve the same cached version of the page to everyone, but when the browser requests the image file, the login check is performed. However, are the images really the only difference between signed-in users and guests?

  • Like 2
Link to comment
Share on other sites

@JanRomero: +1! if the images are the only difference, this is much better.

I have a script that does something along this, maybe it is a good starting point:

pwimg_(as-starting-point).zip

EDIT: found that old thread, where I initially created that script. It has some htaccess rules that also can be a starting point if one want to go the htaccess route: https://processwire.com/talk/topic/4668-protect-original-images-in-siteassetsfiles/#entry46189

Edited by horst
  • Like 3
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...