• 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 » Get Started with Varnish Cache

By Abhishek Ghosh May 2, 2014 7:19 pm Updated on May 2, 2014

Get Started with Varnish Cache

Advertisement

With Cloud Servers, it is easier to spin up a separate server to work as front end. Let us get started with Varnish Cache setup with commands. We talked about Varnish Cache before, we said that; Varnish is a web accelerator for dynamic web pages with lots of content like WordPress. Unlike other client-side proxies or servers (read what is reverse proxy), Varnish was designed from the ground up as a Web accelerator. Varnish works by handling requests before they goes to your backend, whether your backend is Apache2, Nginx – does not matter. If only it has no request cached, it will forward the request to the backend and then cache its output.

 

Get Started with Varnish Cache : Spin a Server

 

We are using Ubuntu 14.04 LTS, 512 MB server will work fine for the most. First update the current packages and install Varnish :

 

Vim
1
2
apt-get update && apt-get upgrade
apt-get install varnish

Edit the daemon options for Varnish to instruct it to load custom configuration:

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
nano /etc/default/varnish
# output; scroll down and you'll get
 
## Alternative 2, Configuration with VCL
#
# Listen on port 6081, administration on localhost:6082, and forward to
# one content server selected by the vcl file, based on the request.  Use a 1GB
# fixed-size cache file.
#
DAEMON_OPTS="-a :6081
             -T localhost:6082
             -f /etc/varnish/default.vcl
             -S /etc/varnish/secret
             -s malloc,256m"
 
# change
# -f /etc/varnish/default.vcl  to
# -f /etc/varnish/user.vcl

Get Started with Varnish Cache

From the configuration above, we need edit the value -s malloc,256m :

Vim
1
2
-s malloc,360m
# for 512mb server, approximately we should allow some RAM left!

Copy default.vcl to your own file :

Vim
1
2
3
cd /etc/varnish && cp default.vcl user.vcl
nano user.vcl
# the file will open

 

Get Started with Varnish Cache : Set up Backend

 

This is default :

Vim
1
2
3
4
backend default {
    .host = "127.0.0.1";
    .port = "80";
}

It is actually caching Apache which is currently on port 80 on the same server, so change accordingly the IP. You should restart Varnish :

Vim
1
service varnish restart

Varnish runs on port 6081, we will edit the file :

Vim
1
2
3
4
sub vcl_fetch
{
    set beresp.ttl = 2h;
}

# We should change Apache’s port, edit /etc/apache2/ports.conf :
nano /etc/apache2/ports.conf

Find NameVirtualHost *:80 and Listen 80 and change 80 in each to another port. We will change to 8080:

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
NameVirtualHost *:8080
Listen 8080
# NameVirtualHost will not be required in later versions
 
# edit /etc/apache2/sites-available/000-default.conf and set virtual host to listen at :
# <VirtualHost *:8080>
# configure Varnish to start on port 80 :
nano /etc/default/varnish
# should look like this
DAEMON_OPTS="-a :80
# Open /etc/varnish/user :
 
nano /etc/varnish/user
# should look like this :
backend default {
    .host = "127.0.0.1";
    .port = "8080";
}
# change host! that is for single server setup
# restart services
service apache2 reload
service varnish restart

This is the basic setup with Varnish. It itself will give you a good polish. Get used with Varnish and tweak the performance. We could install on same server, but actually its better to use a separate server. It makes the load balance management easier.

This Article Has Been Shared 510 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 Get Started with Varnish Cache

  • Free Cloud Storage From Unbuntu One Plus Desktop app for Windows 7

    Free Cloud Storage From Unbuntu One provides 5 GB of Public Cloud Space. Ubuntu One now offers client apps for Windows 7, Linux, iPhone, Android devices.

  • Cloud Load Balancer – Mechanism and Types of Load Balancer

    Cloud Load Balancer is Cloud Computing based system to distribute the load on one server, it can be based on various technologies and complicated levels.

  • In-memory Technology : The Mastery of Big Data

    In-memory technology has the potential to initiate a new computing era. The mastery of Big Data gives the promise of the Real-Time Enterprise to reality.

  • Free Bootstrap CMS : PHP, MySQL Powered With Twitter Bootstrap Design

    Free Bootstrap CMS is a complete CMS powered by PHP, MySQL and comes with customizable Twitter Bootstrap Design. Let us see how it looks and how to install. Free Bootstrap CMS is available on Github as Free Software.   Free Bootstrap CMS : Origin and Source Code     e107 is a free (open-source) content […]

  • Adding Schema.org Structured Data in Genesis Theme

    Adding Schema.org Structured Data in Genesis Theme without using any plugin is quite easy as Genesis has great documentation and has excellent existing markups.

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

  • Advantages of Cloud Server Over Dedicated Server for Hosting WordPress March 26, 2023
  • Get Audiophile-Grade Music on Your Smartphone March 25, 2023
  • Simple Windows Security and Privacy Checklist for 2023 March 24, 2023
  • 7 Best Artificial Intelligence (AI) Software March 24, 2023
  • ESP32 Arduino Water Tank Level Monitoring Using Laser ToF Sensor March 23, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Get Started with Varnish Cache," in The Customize Windows, May 2, 2014, March 27, 2023, https://thecustomizewindows.com/2014/05/get-started-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