Adding custom "logged in" variable to url string for Varnish

Started by merm, May 24, 2011, 02:33:09 PM

Previous topic - Next topic

merm

I recently installed Varnish, and I love it. It's reduced the load on my servers substantially. One thing I'd like to do though is provide non-cached versions of pages for logged-in forum members. (Since I don't care if guests that are browsing the forums are seeing an old version of a page.)

Varnish allows me to tell it to "ignore" all pages that contain a certain URL string, so I was thinking one effective way to deal with this would be to append an &loggedin=1 or something similar to the end of the url strings for logged in users. I could then just tell Varnish to not cache these pages.

Is there a way I can accomplish this? Or is there another way that anyone knows of that I can tell varnish to not deliver cached pages for logged-in users?

SlammedDime

SlammedDime
Former Lead Customizer
BitBucket Projects
GeekStorage.com Hosting
                      My Mods
SimpleSEF
Ajax Quick Reply
Sitemap
more...
                     

merm

Hmm. This looks really interesting, but it talks about caching for logged in users, I want to NOT cache for logged in users, and cache for everyone else.

Something like that

Quote from: merm on May 24, 2011, 07:48:49 PM
Hmm. This looks really interesting, but it talks about caching for logged in users, I want to NOT cache for logged in users, and cache for everyone else.

Look for the SMFCookie... if it's there, then don't cache. It's the cookie name you specify in the admin section.

praveenkv1988

You can use the login cookie or the url to make it not to cache the content.
Happy Hosting [nofollow]
Managed Windows and Linux VPS [nofollow] with CPanel/Plesk/DirectAdmin.
Managed Windows / Linux Dedicated Servers.

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

merm

Sorry it took me so long to reply to this.

No, I haven't figured it out yet. Unfortunately Varnish configuration is a little above my pay grade still, and I'm not sure how to use URL filtering properly to not cache pages for logged-in users without having a really long list of opt-out url's. The cookie evaluation seems like the most elegant solution, but I'm not sure how to accomplish it.

kat


merm

Yeah, actually someone helped me and we basically accomplished it by doing an evaluation of the cookie the user has. SMF writes a session cookie basically upon successful login, so anyone that had that cookie we exempt from caching.

Angelina Belle

Sounds very sensible.  Glad you figured it out. I hope you won't mind that I've marked this topic "Solved"
They pay me DOUBLE the usual rate when I do that. :)
Never attribute to malice that which is adequately explained by stupidity. -- Hanlon's Razor

merm

I don't mind at all! Glad to contribute to your wealth and success ! ;)

Aleksi "Lex" Kilpinen

Oh, I'd gladly even triple AB's salary for helping out with support lately. ;)
Sadly, we can triple nothing - and it's still nothing :P
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: