• 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 822 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, 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

Get new posts by email:

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 (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • What is Configuration Management February 5, 2023
  • What is ChatGPT? February 3, 2023
  • Zebronics Pixaplay 16 : Entry Level Movie Projector Review February 2, 2023
  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023

About This Article

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

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

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

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

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

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT