How to Configure Server-Level Cache on Nginx (basic example)

  Рет қаралды 28,164

Tony Teaches Tech

Tony Teaches Tech

Күн бұрын

Learn how to implement Nginx server-level caching in this tutorial that will walk you through a basic example of how to configure the proxy_cache and proxy_cache_path directives.
Code snippets and more at tonyteaches.te...
Check out my vlog channel ‪@TonyFlorida‬
#nginx #cache

Пікірлер: 89
@Dr_Dude
@Dr_Dude 2 жыл бұрын
The best, shortest, most succinct illustrated explanation on how to setup nginx web cache proxy. Thank you!
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
Glad it was helpful! That's what I was going for with this one :)
@davidsun9026
@davidsun9026 2 жыл бұрын
Thanks. Sometimes I just get tired of having to read through a mountain of man pages to get started. Glad you posted this up
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
Glad it was helpful!
@vargasbj
@vargasbj Жыл бұрын
Hello from Costa Rica. This is amazing. You explained so detailed and clear and straigforward. Huge thanks
@TonyTeachesTech
@TonyTeachesTech Жыл бұрын
You're welcome!
@tf1n
@tf1n 2 жыл бұрын
Thank you, Tony! I was feeling ambiguity around the process of configuring Nginx for this, but you have reaffirmed how simple it can be from the Nginx documentation. This video helped me make huge gains for a system design project at a programming school. Blessings to you!
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
You're welcome Cameron
@dubeayiokorie4546
@dubeayiokorie4546 3 жыл бұрын
Great video my brother, keep up the clean work
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Thank you, I will!
@nomanjaved7741
@nomanjaved7741 3 жыл бұрын
Your way of explanation is extra ordinary awesome.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Thanks a lot 😊
@kimleansy929
@kimleansy929 3 ай бұрын
bro I love you, thanks for this
@datajunkie3427
@datajunkie3427 2 жыл бұрын
This tutorial is more than awesome! Thanks bud. What happens if the server at 8000 is dead, will the client still get a copy of the site since it's cached?
@marcioslsouza
@marcioslsouza 2 жыл бұрын
Hey Tony! Great video explaining how the CDN words on NGINX. I would like to ask you how all this configuration would work in secure mode (SSL) port 443 rather than in port 80?
@LryuzakiLN
@LryuzakiLN Жыл бұрын
Caching doesn't seem to work in Django projects, can you make a video on how to achieve it? I don't think you will be able to do it imo.
@PeterBatah
@PeterBatah Жыл бұрын
Thank you so much for sharing your time and expertise with us Tony. Much appreciated. How would you apply this caching method to Nginx when it is being used as a reverse proxy for multiple sites. Eg. your YT video on multiple Wordpress sites. Have a good one!
@ramguntha
@ramguntha 3 жыл бұрын
Thanks for the informative video. Question(s): 1. Can this cache be used for Json data as well? How do we make sure that nginx does not get confused with the auth tokens that keep changing with every request? 2. When it comes to the static content that is living on the same physical box, how does the caching server make it faster?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Caching will likely make it faster. Should work on json data too
@livetvuhddotcom4510
@livetvuhddotcom4510 Жыл бұрын
Hi, your video is so easy to understand. I am new in nginx. I am trying to learn nginx by watching your video. I have an another question. Can you make any video for VOD Streaming Cache server? like, i want to make a cache server for mp4 file. also i want to know about cache file size? if main file size 1 gb then what will be the cache file size? Thanks.
@IosifHamlatzis
@IosifHamlatzis Жыл бұрын
thnx I was wondering since I have an nginx server (let's name it "haha") already running for HLS & DASH streaming and don't want to mess it up, is there a way to use another server for caching? So someone is watchign a live stream from "haha" can I have this stream also cached?
@dineshgoyal092
@dineshgoyal092 3 жыл бұрын
well explained!!
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Thanks!
@cloudsystem3740
@cloudsystem3740 3 жыл бұрын
thank you so much
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
You're welcome!
@aniketshinde7716
@aniketshinde7716 3 жыл бұрын
Hi Tony... video is very informative and covers basic caching. I have a query, while setting up the cache, you made the configuration to cache anything. So if I want to cache a specific image or web page, in that case how would I configure. Thanks in advance.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Sorry, I don't have this information
@sheriffcrandy
@sheriffcrandy Жыл бұрын
x-proxy-cache response header isn't showing in network tab in dev tools. My setup is nginx and gunicorn django web app.
@saeed.rahimi.manesh
@saeed.rahimi.manesh 3 жыл бұрын
wowwwwww, awesome
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Thanks
@waelsadek81
@waelsadek81 Жыл бұрын
1:07 Isn't ETag used for caching ?
@NoCommunists
@NoCommunists Жыл бұрын
Thanks for your tutorial, but I want to cache video for faster serving on my server, is it possible without using CDN ? (because it's kinda expensive) Is there any way to cache video like ready for serving for any visitor visit a video URL (.mp4 URL) that been already cached on server ?
@motidana4883
@motidana4883 3 жыл бұрын
very productive. thankyou for such great content. I have a small question. If I am looking to serve static content (js,css, png, gif, etc) and couple of REST API dynamic PHP calls as well, and say i have to serve these static assets at the same time to 20,000 concurrent users, will this approach to add cache server in front of a origin nginx server, will that be helpful, if so to what extent?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
This type of cache is only helpful for caching dynamic content that doesn't change too often. I don't see it helping much for static content
@motidana4883
@motidana4883 3 жыл бұрын
​@@TonyTeachesTech thanks for your reply so do you see any good technique to optimize static content delivery from with in Nginx or CDN is only way to go?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
@@motidana4883 Sorry, I'm not familiar with optimizing static content delivery in Nginx. I would need to do more research on this topic
@merkava1988
@merkava1988 2 жыл бұрын
Will it be functional in caching like squid proxy?
@RaviKumar-fx5dz
@RaviKumar-fx5dz 3 жыл бұрын
Thanks a lot Toni bro. Can you pls how to configure lscache on openlitespeed server for non wordpress sites? Happy new year bro.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
You're welcome! Is this what you're referring to? openlitespeed.org/kb/openlitespeed-cache-module/ -Tony
@engchoontan8483
@engchoontan8483 Жыл бұрын
The transparent-proxy and cache probably cannot work for "win11 file-manager" due to the sabotaged browers and other- OS.sss with advertising being number-1 and everything else (games) will only load after forced-advertising(duration, times) thus making advertising the owner of devices. If the video is down due to advertising-servers being cut-off due to internet tier-one exchanges in disagreement due to war or just women-meeting micro-managing... just boot into linux and use the browser for something else like internet-TV
@engchoontan8483
@engchoontan8483 Жыл бұрын
China learnt to hack using the advertising due to the size-of payload possible and the bypass of security and the ... of permissions and the control of hardware and ... older-OS.sss should be in the bootloader-chainloader(list-sequence of defaults)
@armanism24
@armanism24 3 жыл бұрын
please make a video on dynamic caching
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Something I can put on my list to look into
@techwithshudarsan559
@techwithshudarsan559 3 жыл бұрын
Perfect!!
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Great
@Maazwebsitetech
@Maazwebsitetech 3 жыл бұрын
Hi! Im from morocco and i ask how to install nginex in centos 7 and in centos web panel Thanks for your informatiom
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Hello, I'm not too familiar with CentOS. This tutorial should help you though www.digitalocean.com/community/tutorials/how-to-install-nginx-on-centos-7
@Maazwebsitetech
@Maazwebsitetech 3 жыл бұрын
Thanks
@C00ltronix
@C00ltronix 3 жыл бұрын
I think Centminmod can install a complete nginx stack on CentOS
@bashardlaleh2110
@bashardlaleh2110 3 жыл бұрын
i wish you would explain all the caching parameters you wrote more clearly , thanks
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Sorry for that
@JustinAvery
@JustinAvery 3 жыл бұрын
Amazing, but none of my cache files are getting written and therefore I'm getting no cache hits. Any idea why? This is using a nginx proxy with proxy_pass, and using proxy_ssl_session_reuse (these are the only differences I can see)
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Hmm I'm not sure why that's happening for you
@amalms6573
@amalms6573 3 жыл бұрын
Hi Tony... Why do we need to change the website listening port? Can we do this without changing the website port?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
This is so the cache can communicate with the frontend. You can pick any ports you'd like
@whatthefunction9140
@whatthefunction9140 Ай бұрын
Hi tony
@nomanjaved7741
@nomanjaved7741 2 жыл бұрын
How I can set the cache on WordPress website that is pointing via domain.
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
This video should help
@nomanjaved7741
@nomanjaved7741 2 жыл бұрын
@@TonyTeachesTech I am not using reverse proxy server in my case.
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
@@nomanjaved7741 Perhaps a plugin like W3 Total Cache will help you
@nomanjaved7741
@nomanjaved7741 2 жыл бұрын
@@TonyTeachesTech How I can configure it.
@TonyTeachesTech
@TonyTeachesTech 2 жыл бұрын
@@nomanjaved7741 Check this out kzbin.info/www/bejne/f2nZgXxqjaqEfJo
@simplemindedperson
@simplemindedperson 3 жыл бұрын
what if SSL has been applied to the original server? change the listened port number from 80 to 443?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Yep
@nomanjaved6658
@nomanjaved6658 3 жыл бұрын
where I can add 301 redirects after setting proxy server for caching.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
In your Nginx config file
@sanjayshorey4225
@sanjayshorey4225 3 жыл бұрын
Hi Tony, nginx is serving old files instead of new updated files of my angular application. New features aren't visible. I checked in Network tab of chrome console. It shows old files instead of new files. Can you suggest a solution? I'm tired of finding solution and can't figure out what to do.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
I'm not sure why that's happening to you, sorry
@chrisivonne3739
@chrisivonne3739 3 жыл бұрын
Does this work for Bitnami NGINX? The var/cache/nginx folder doesn't get auto-created and manually doing so causes the directory to be unwritable resulting in the response header to be missing caching instructions.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Hopefully Nick will be able to help you out :)
@ErickJohnCuevas
@ErickJohnCuevas 3 жыл бұрын
will it work in cloudflare dns? or localhost only? thank you Tony.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Erick, not sure about Cloudflare
@MemesOfMirzapur
@MemesOfMirzapur 3 жыл бұрын
This method is not working with wordpress, like when I add a new post old cache should be deleted also in update. Could you please make a video on proper caching for WordPress in NGINX?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
Oh yes, we'd have to do a bit more than this basic example. I can look into this for a future video.
@C00ltronix
@C00ltronix 3 жыл бұрын
With Wordpress you can user Redis or fastCGI at server level and then have a plugin to delete cache when needed. Or get a easy server stack such as Wordops, Centminmod etc. that makes it easy to setup and change stuff.
@armanism24
@armanism24 3 жыл бұрын
@@C00ltronix Ofcourse I used this method earlier but I want to do it manually.
@C00ltronix
@C00ltronix 3 жыл бұрын
@@armanism24 I think you can add a cron job, maybe?
@armanism24
@armanism24 3 жыл бұрын
@@C00ltronix No, I believe for that we have to do scripting ( like - bash, python )
@pradeeprajvanshi2435
@pradeeprajvanshi2435 3 жыл бұрын
How can we use caching when we have user logged in sessions.
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
I'm not sure how to combine the concepts of sessions with server caching
@anirudhya_g
@anirudhya_g 3 жыл бұрын
can I use the same method to cache notion in my nginx server and use it offline
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
What do you mean by "cache notion"?
@anirudhya_g
@anirudhya_g 3 жыл бұрын
@@TonyTeachesTech yes
@vashthestampede3459
@vashthestampede3459 3 жыл бұрын
how do you even install it?
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
You can install Nginx with the following command: sudo apt-get install nginx
@vashthestampede3459
@vashthestampede3459 3 жыл бұрын
@@TonyTeachesTech Oh! I thought this was like a different NGINX module or something. Thanks for the response!
@vashthestampede3459
@vashthestampede3459 3 жыл бұрын
@@TonyTeachesTech Just wanted to let you know I was able to set this up and I can continue my learning from there. Thanks for showing the basics. Very helpful!
@TonyTeachesTech
@TonyTeachesTech 3 жыл бұрын
@@vashthestampede3459 Happy to hear that!
Nginx | Cache Introduction | Docker
39:26
Very Academy
Рет қаралды 8 М.
The NGINX Crash Course
50:53
Laith Academy
Рет қаралды 490 М.
Spongebob ate Michael Jackson 😱 #meme #spongebob #gmod
00:14
Mr. LoLo
Рет қаралды 10 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 114 МЛН
ЭТО НАСТОЯЩАЯ МАГИЯ😬😬😬
00:19
Chapitosiki
Рет қаралды 3,1 МЛН
NGINX Tutorial - What is Nginx
14:32
TechWorld with Nana
Рет қаралды 190 М.
Настройка кэширования в Nginx
16:29
Поддержка Сайтов :: Метод Лаб
Рет қаралды 3,9 М.
Coding a Web Server in 25 Lines - Computerphile
17:49
Computerphile
Рет қаралды 338 М.
Everything you need to know about HTTP Caching
13:33
the roadmap
Рет қаралды 156 М.
Cache Systems Every Developer Should Know
5:48
ByteByteGo
Рет қаралды 495 М.
Configure NGINX as a Reverse Proxy
16:43
NGINX
Рет қаралды 217 М.
Best Practices for Caching
38:04
NGINX
Рет қаралды 20 М.
Harder Drive: Hard drives we didn't want or need
36:47
suckerpinch
Рет қаралды 1,7 МЛН
Apache vs NGINX
7:53
IBM Technology
Рет қаралды 300 М.
Proxy vs Reverse Proxy (Real-world Examples)
5:17
ByteByteGo
Рет қаралды 567 М.
When your brother is praying 🤲
0:15
Daud Kim
Рет қаралды 10 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
0:45
路飞与唐舞桐
Рет қаралды 18 МЛН
Duniya ki sab se pyari awaz 🕋 #azan #islamicprayer #quran
0:12
Bahadur Hussain
Рет қаралды 33 МЛН
МЕЙРАМБЕК ҚЫЗДЫ БОЛДЫ ❤️🫶🏻
0:20
Ән - көңілдің ажары.
Рет қаралды 144 М.
😱ШОК! АГАТА УДАРИЛА ТРЕНЕРА! #бассейн #sports
0:23
МОЯ СТИХИЯ | ПЛАВАНИЕ | МОСКВА
Рет қаралды 6 МЛН
🤣😱😂Smart Appliances! New Gadgets, Versatile Utensils, Tool Items #shorts #gadgets
0:12