LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-31-2014, 04:34 AM   #1
noriodesousa
LQ Newbie
 
Registered: Jan 2014
Posts: 3

Rep: Reputation: Disabled
Varnish caching based on cookies


Hi guys,

I run a Simple Machines forum and have Varnish in front of it. I'd like to cache all anonymous requests. This should be easy enough as SMF sets a cookie 'SMFCookie132' if you log in. This cookie can be renamed to anything I like.

So my question is: How do I configure Varnish to cache for everyone except those with this cookie?

Thanks a stack!
 
Old 01-31-2014, 06:57 AM   #2
noriodesousa
LQ Newbie
 
Registered: Jan 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Okay so I've got something that works pretty well. It checks for the SMFCookie132 cookie and, if it finds it, it deletes ALL the cookies. Varnish will serve cached objects if there are no cookies.

Code:
# recv
sub vcl_recv {
        # if SMFCookie132 is not there...
        if ( ! req.http.cookie ~ "SMFCookie132") {
                # kill ALL cookies
                unset req.http.Cookie;
        }
}
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What cookies does linuxquestions send a user? Must I enable cookies to keep logged in? winger9 Linux - Newbie 2 01-18-2014 07:24 PM
cookies in Firefox - can Google read Yahoo! cookies? nerdofdarkness Linux - Newbie 9 11-11-2013 01:04 AM
Disable caching for certain URLs in varnish? How to? linuxlover.chaitanya Linux - Server 3 04-18-2013 07:34 AM
Varnish Backend jagatveer Linux - Server 1 09-12-2012 09:35 AM
Get Glossy with Varnish jeremy LQ Articles Discussion 0 03-14-2008 11:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration