• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Advanced Tweaks and Optimization for Varnish Cache

By Abhishek Ghosh May 5, 2014 5:12 am Updated on May 5, 2014

Advanced Tweaks and Optimization for Varnish Cache

Advertisement

Varnish Cache usually works the best out of the box. However, minimum tweaks and optimization can make Varnish to work better with WordPress. When we are talking bout WordPress, obviously W3 Total Cache configuration comes in to question – because W3 Total Cache has separate option for configuring W3 Total Cache for Varnish. So, how should we pass the page requests to get the maximum out from Varnish Cache? Read Get Started with Varnish Cache for setting up of Varnish Cache in case you have not installed Varnish Cache yet. We are writing the things divided in to two sub headers – general tweaks and specific for WordPress with W3 Total Cache configuration.

 

Advanced Tweaks and Optimization for Varnish Cache

 

So, actually we are serving content via Varnish Cache – not Apache2 and PHP handlers directly. In the previous guide we changed the port of Varnish to 8080, if we kept it to default; if your server’s IP was 125.23.24.987, if you point towards :

Vim
1
http://125.23.24.987:6081

You should be able to view a copy of the webpage. In fact, you can keep it to default and make Apache2 to Listen at port 80 and Port 8080. Virtual Host, in that case should handle port 8080 only. This works great for adding load balancer – read Load Balancer Service from Rackspace Guide. Load balancer should Listen with http:80 method, use Round Robin Algorithm and as node; your server’s port 6081 should serve the content to load balancer. As load balancer has a different IP and we can control access precisely, by no way any request will go directly to Apache2 and PHP handlers directly. You domain example.com is fully cached. But, for WordPress we need to keep the Admin area cache free :

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
nano /etc/varnish/user.vcl
# Edit the file like below
sub vcl_recv
{
    if (req.http.host ~ "example.com" ||
        req.url ~ "^/admin")
    {
        return (pass);
    }
}
# restart, varnish should be reloaded first
service varnish restart
service apache2 reload

You might face Guru Meditation Error with improper setup.

This editing will work great for the most :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
backend default {
    .host = "127.0.0.1";  # backend
    .port = "8080";       # Port of backend
    .probe = {
        .url = "/";
        .timeout = 34ms;
        .interval = 1s;
        .window = 10;
        .threshold = 8;
    }
}
 
sub vcl_recv
{
   # for WordPress the admin area
   if (req.http.host ~ "example.com" ||
        req.url ~ "^/admin" ||
        req.http.Cookie ~ "logged_in" ||
        req.request == "POST")
    {
        return (pass);
    }
 
    # Set / unset cookies
    unset req.http.Cookie;
 
    # Set Grace Time to one hour
    set req.grace = 1h;
}
 
sub vcl_fetch
{
    # Set the TTL for cache object
    set beresp.ttl = 5m;
 
    # Set Grace Time
    set beresp.grace = 1h;
}

You can read the docs :

Vim
1
https://www.varnish-cache.org/docs/2.1/index.html

 

Advanced Tweaks and Optimization for Varnish Cache : For WordPress

 

It actually does not matter whether you are configuring W3 Total Cache with Varnish or not as long you are serving content via a load balancer – W3 Total Cache can not give much higher performance with our setup.

Advanced Tweaks and Optimization for Varnish Cache

Yet, if you want to add the servers, add main server’s IP where Varnish is running. For multiple server, the configuration would be more complicated if you involve W3 Total Cache :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# taken from highscalability.com
# written by Jeff
 
backend server1 {
  .host = "10.0.0.10";
}
backend server2{
  .host = "10.0.0.11";
}
director multi_servers1 round-robin {
  {
    .backend = server1;
  }
  {
    .backend = server2;
  }
}
director multi_servers2 random {
  {
    .backend = server1;
  }
  {
    .backend = server2;
  }
}

There is enough change that, W3TC or any PHP script would not follow the logic and ultimately you’ll end up serving 503 pages. You can end up complicating the simple setup :

Vim
1
http://wordpress.org/support/topic/plugin-w3-total-cache-varnish-cache-not-purged-sends-get-requests-instead-of-purge

For our way of guide with Rackspace Cloud Server and Loadbalancer, we need not to involve Varnish Cache.

Tagged With advanced wordpress optimization , varnish optimizing

This Article Has Been Shared 204 Times!

Facebook Twitter Pinterest
Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Orthopaedic Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Advanced Tweaks and Optimization for Varnish Cache

  • Open Source Hardware : Less Costly Works Best

    Open Source Hardware provides hardware specifications like Open Source Software, which are publicly available,you can buy the smallest parts and build yourself.

  • Open Source Free Health : Health Will Not Be Costly

    Open Source Free Health can make a Glucose Meter of few dollars, a Robotic Surgical unit of few hundred dollars. Overall burden of health is made by the brands.

  • Cloud Computing and Relationship with Service Oriented Architecture

    Cloud Computing and Service Oriented Architecture (SOA) are two complementary concepts that can be used independently or in agreement.

  • PaaS : Everything You Wanted To Know

    PaaS or Platform as a Service has a great opportunity to transform application development. PaaS is intended for application deployment, still website can run.

  • Cloud Based Mobile App for Keyless Entry or Build Something More

    Cloud Based Mobile App for Keyless Entry or Build Something More with Selfstarter which is distributed by Lockitron as Free repo. Here is how to get started.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

You can subscribe to our Free Once a Day, Regular Newsletter by clicking the subscribe button below.

Click To Subscribe

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (20K Followers)
  • Twitter (4.9k Followers)
  • Facebook (5.8k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.2k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Domain-Driven Design (DDD)? January 23, 2021
  • Top 10 Anti Hacking Software for Microsoft Windows January 22, 2021
  • What is Software Modernization? January 21, 2021
  • Cloud Computing : Cybersecurity Tips for Small Business Owners January 20, 2021
  • Arduino : Independently Blink Multiple LED January 18, 2021

 

About This Article

Cite this article as: Abhishek Ghosh, "Advanced Tweaks and Optimization for Varnish Cache," in The Customize Windows, May 5, 2014, January 23, 2021, https://thecustomizewindows.com/2014/05/advanced-tweaks-optimization-varnish-cache/.

Source:The Customize Windows, JiMA.in

 

This website uses cookies. If you do not want to allow us to use cookies and/or non-personalized Ads, kindly clear browser cookies after closing this webpage.

Read Cookie Policy.

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2021 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy