Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Our architecture consists of a front-end cache that most read only users obtain their data from directly. The front-end cache sits in front of a farm of webservers that serve pages written in PHP. We need to be able to detect certain conditions at the front-end cache level and pass those values through to the back-end via HTTP headers. For example we would like to manually tag the carrier network based on the IP address. So, for incoming traffic if the user is say coming from an IP address in the range of "41.202.192.0"/19 we would tag them as being a Orange Cameroon user by setting the appropriate HTTP request header, e.g., X-Carrier = "Orange Cameroon".

Based on the setting of this header we would like to vary the cache and serve a different banner to the end user. How would you go about doing this? Keep in mind that we don't want to pollute the cache and we also don't want to create too many small cache segments.

Assumptions: You can assume that the X-Carrier has already been detected in our cache. So, for the purposes of your test you can just set this value manually in your example script.

share|improve this question
add comment

1 Answer

Varnish as a front end cache sounds like a good fit here https://www.varnish-cache.org/

It is incredibly fast and can easily handle thousands of page requests per second on fairly modest hardware running Linux.

To add headers, select appropriate backends, determine cache life e.t.c. there is a scripting language built into Varnish that compiles to C when Varnish starts. Look at the VCL page for details of what you can do https://www.varnish-cache.org/docs/3.0/reference/vcl.html

Also have a look at https://www.varnish-cache.org/trac/wiki/VCLExamples for real world examples of how people have deployed VCL within Varnish to solve similar problems to yours https://www.varnish-cache.org/trac/wiki/VCLExamples

share|improve this answer
    
both varnish or nginx could help with this project. –  WojonsTech Oct 2 '12 at 19:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.