[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"\u002Fblog\u002Fhow-to-clear-nginx-cache":3,"$fA6ZdLu73V4sk8Arvl-mDhZ_1tRG9KQ1Z9GjegIVUlDk":280,"i-local-icon:calendar-days":284,"i-local-icon:tag":289,"i-local-icon:eye":291},{"id":4,"title":5,"body":6,"categories_slug":268,"comment_count":271,"date_published":272,"description":273,"extension":274,"meta":275,"navigation":92,"path":276,"seo":277,"stem":278,"__hash__":279},"content\u002Fblog\u002F12.how-to-clear-nginx-cache.md","How to clear NGINX cache",{"type":7,"value":8,"toc":261},"minimark",[9,13,18,23,27,33,37,62,68,161,165,168,193,203,207,210,250,254,257],[10,11,5],"h1",{"id":12},"how-to-clear-nginx-cache",[14,15],"meta-card",{":categories":16,":date":17},"categories_slug","date_published",[19,20,22],"h2",{"id":21},"overview","Overview",[24,25,26],"p",{},"One major feature of the NGINX web server is caching, which can significantly improve website performance by storing frequently accessed data and delivering it quickly to users. However, there are situations where you might need to clear the NGINX cache, such as updating content or resolving caching issues. In this guide, we'll walk you through the steps on how to clear the NGINX cache.",[28,29,30],"blockquote",{},[24,31,32],{},"Unfortunately, NGINX doesn't provide a direct CLI command to delete the entire cache. So the process to delete the cache has to be done manually.",[19,34,36],{"id":35},"step-1-identify-nginx-cache-directory","Step 1: Identify NGINX Cache Directory",[24,38,39,40,44,45,48,49,53,54,57,58,61],{},"The first step is to locate the NGINX cache directory on your server. The cache path is typically defined in the NGINX configuration file, often named ",[41,42,43],"em",{},"nginx.conf"," or ",[41,46,47],{},"default.conf"," which can be found in ",[50,51,52],"strong",{},"\u002Fetc\u002Fnginx",". Open the file using a text editor and search for the ",[41,55,56],{},"\"proxy_cache_path\""," directive (or ",[41,59,60],{},"\"fastcgi_cache_path\""," if using fastcgi). This directive specifies the location of the cache on your server.",[24,63,64,65],{},"So in the example below, the cache path is: ",[41,66,67],{},"\u002Fetc\u002Fnginx\u002Fcache",[69,70,75],"pre",{"className":71,"code":72,"language":73,"meta":74,"style":74},"language-bash shiki shiki-themes github-dark","# NGINX config file - typically found in \u002Fetc\u002Fnginx\u002Fnginx.conf\n\n# Cache path.\nproxy_cache_path \u002Fetc\u002Fnginx\u002Fcache levels=1:2 keys_zone=MYAPP:100m max_size=5g inactive=60m use_temp_path=off;\n\n# Alternatively, if using fastcgi, cache path.\nfastcgi_cache_path \u002Fetc\u002Fnginx\u002Fcache levels=1:2 keys_zone=MYAPP:100m max_size=5g inactive=60m use_temp_path=off;\n","bash","",[76,77,78,87,94,100,130,135,141],"code",{"__ignoreMap":74},[79,80,83],"span",{"class":81,"line":82},"line",1,[79,84,86],{"class":85},"sAwPA","# NGINX config file - typically found in \u002Fetc\u002Fnginx\u002Fnginx.conf\n",[79,88,90],{"class":81,"line":89},2,[79,91,93],{"emptyLinePlaceholder":92},true,"\n",[79,95,97],{"class":81,"line":96},3,[79,98,99],{"class":85},"# Cache path.\n",[79,101,103,107,111,114,117,120,123,126],{"class":81,"line":102},4,[79,104,106],{"class":105},"svObZ","proxy_cache_path",[79,108,110],{"class":109},"sU2Wk"," \u002Fetc\u002Fnginx\u002Fcache",[79,112,113],{"class":109}," levels=1:2",[79,115,116],{"class":109}," keys_zone=MYAPP:100m",[79,118,119],{"class":109}," max_size=5g",[79,121,122],{"class":109}," inactive=60m",[79,124,125],{"class":109}," use_temp_path=off",[79,127,129],{"class":128},"s95oV",";\n",[79,131,133],{"class":81,"line":132},5,[79,134,93],{"emptyLinePlaceholder":92},[79,136,138],{"class":81,"line":137},6,[79,139,140],{"class":85},"# Alternatively, if using fastcgi, cache path.\n",[79,142,144,147,149,151,153,155,157,159],{"class":81,"line":143},7,[79,145,146],{"class":105},"fastcgi_cache_path",[79,148,110],{"class":109},[79,150,113],{"class":109},[79,152,116],{"class":109},[79,154,119],{"class":109},[79,156,122],{"class":109},[79,158,125],{"class":109},[79,160,129],{"class":128},[19,162,164],{"id":163},"step-2-remove-cached-files","Step 2: Remove Cached Files",[24,166,167],{},"Log in to your server via SSH and run the following command using the correct path that you retrieved in step 1:",[69,169,171],{"className":71,"code":170,"language":73,"meta":74,"style":74},"# Clear entire cache using directory retrieved in step 1.\nsudo rm -rf \u002Fetc\u002Fnginx\u002Fcache\n",[76,172,173,178],{"__ignoreMap":74},[79,174,175],{"class":81,"line":82},[79,176,177],{"class":85},"# Clear entire cache using directory retrieved in step 1.\n",[79,179,180,183,186,190],{"class":81,"line":89},[79,181,182],{"class":105},"sudo",[79,184,185],{"class":109}," rm",[79,187,189],{"class":188},"sDLfK"," -rf",[79,191,192],{"class":109}," \u002Fetc\u002Fnginx\u002Fcache\n",[24,194,195,198,199,202],{},[50,196,197],{},"Note:"," Exercise caution when using the ",[50,200,201],{},"'rm -rf'"," command, as it will permanently delete files and directories without confirmation.",[19,204,206],{"id":205},"step-3-restart-nginx","Step 3: Restart NGINX",[24,208,209],{},"After clearing the cache, it's essential to restart NGINX to apply the changes. You can do this by using the following command:",[69,211,213],{"className":71,"code":212,"language":73,"meta":74,"style":74},"sudo service nginx restart\n\n# or alternatively\nsudo systemctl restart nginx\n",[76,214,215,228,232,237],{"__ignoreMap":74},[79,216,217,219,222,225],{"class":81,"line":82},[79,218,182],{"class":105},[79,220,221],{"class":109}," service",[79,223,224],{"class":109}," nginx",[79,226,227],{"class":109}," restart\n",[79,229,230],{"class":81,"line":89},[79,231,93],{"emptyLinePlaceholder":92},[79,233,234],{"class":81,"line":96},[79,235,236],{"class":85},"# or alternatively\n",[79,238,239,241,244,247],{"class":81,"line":102},[79,240,182],{"class":105},[79,242,243],{"class":109}," systemctl",[79,245,246],{"class":109}," restart",[79,248,249],{"class":109}," nginx\n",[19,251,253],{"id":252},"conclusion","Conclusion",[24,255,256],{},"Clearing the NGINX cache is a straightforward process that ensures your web server delivers the latest content to users. Whether you're updating your website or troubleshooting caching issues, following these steps will help you effectively manage your NGINX cache.",[258,259,260],"style",{},"html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .svObZ, html code.shiki .svObZ{--shiki-default:#B392F0}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}",{"title":74,"searchDepth":89,"depth":89,"links":262},[263,264,265,266,267],{"id":21,"depth":89,"text":22},{"id":35,"depth":89,"text":36},{"id":163,"depth":89,"text":164},{"id":205,"depth":89,"text":206},{"id":252,"depth":89,"text":253},[269,270],"nginx","ubuntu",null,"2024-01-10","There are situations where you might need to clear the NGINX cache, such as updating content or resolving caching issues. In this guide, we'll walk you through the steps on how to clear the NGINX cache.","md",{},"\u002Fblog\u002Fhow-to-clear-nginx-cache",{"title":5,"description":273},"blog\u002F12.how-to-clear-nginx-cache","XD0jy6bscjEU7VQBK_jK6p6wOpCO0psh7qkxGo9GgNM",[281],{"id":282,"name":276,"count":283},12,7987,{"left":285,"top":285,"width":286,"height":286,"rotate":285,"vFlip":287,"hFlip":287,"body":288},0,24,false,"\u003Cpath\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\"\n    d=\"M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 0 1 2.25-2.25h13.5A2.25 2.25 0 0 1 21 7.5v11.25m-18 0A2.25 2.25 0 0 0 5.25 21h13.5A2.25 2.25 0 0 0 21 18.75m-18 0v-7.5A2.25 2.25 0 0 1 5.25 9h13.5A2.25 2.25 0 0 1 21 11.25v7.5m-9-6h.008v.008H12zM12 15h.008v.008H12zm0 2.25h.008v.008H12zM9.75 15h.008v.008H9.75zm0 2.25h.008v.008H9.75zM7.5 15h.008v.008H7.5zm0 2.25h.008v.008H7.5zm6.75-4.5h.008v.008h-.008zm0 2.25h.008v.008h-.008zm0 2.25h.008v.008h-.008zm2.25-4.5h.008v.008H16.5zm0 2.25h.008v.008H16.5z\" \u002F>",{"left":285,"top":285,"width":286,"height":286,"rotate":285,"vFlip":287,"hFlip":287,"body":290},"\u003Cg\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\">\n    \u003Cpath\n      d=\"M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.1 18.1 0 0 0 5.224-5.223c.54-.827.368-1.908-.33-2.607l-9.583-9.58A2.25 2.25 0 0 0 9.568 3\" \u002F>\n    \u003Cpath d=\"M6 6h.008v.008H6z\" \u002F>\n  \u003C\u002Fg>",{"left":285,"top":285,"width":286,"height":286,"rotate":285,"vFlip":287,"hFlip":287,"body":292},"\u003Cg\n    fill=\"none\"\n    stroke=\"currentColor\"\n    stroke-linecap=\"round\"\n    stroke-linejoin=\"round\"\n    stroke-width=\"1.5\">\n    \u003Cpath\n      d=\"M2.036 12.322a1 1 0 0 1 0-.639C3.423 7.51 7.36 4.5 12 4.5c4.638 0 8.573 3.007 9.963 7.178c.07.207.07.431 0 .639C20.577 16.49 16.64 19.5 12 19.5c-4.638 0-8.573-3.007-9.963-7.178\" \u002F>\n    \u003Cpath d=\"M15 12a3 3 0 1 1-6 0a3 3 0 0 1 6 0\" \u002F>\n  \u003C\u002Fg>"]