0 likes | 3 Views
"Learn two simple and effective ways to solve the 'Add Expire Headers' issue on your WordPress website. This guide will help improve your site's performance, boost loading speed, and enhance SEO by properly configuring cache expiration. Whether you're a beginner or an advanced user, these easy fixes will help you optimize your site in no time!
E N D
2EasyWaysToSolve“AddExpireHeaders”inWordPressWebsite Mostpeopledon’tunderstandwhatare“ExpireHeaders”andhowtheyhelpinwebsitespeed.OtherpeoplearenotabletoaddthisfeatureinWordPress. Let’strytomakeiteasytounderstandforanyoneandeveryone. Weneedtounderstandabitabouthowbrowsershelptoimproveuserexperienceon awebsite. AllbrowserapplicationsuseacachetostorecertainmediaorresourcessuchasCSS files. Thiscachingaction,decreasespageloadingtime,translatingintoadelightfuluser experience. Animportantthingtonoteisthatthesefilesareonesthatarenotchangedfrequently.A webbrowserwillstorethesefilesinthecache.Whenthepageisrequestedagain,the fileswillbeloadedthroughthebrowsercacheinsteadofthe webserver. Abrowser’s cachecannotholdontoawebsite’sfileslikeimages,CSS,Javascript, etc.) forever.Thesefilesneedtobediscardedfromthecacheaftersometime.Thenfreshdata isrequestedfromthe webserver.
ThisisWHERE“ExpireHeaders”willhelpyoumakeafasterloadingweb page. Gotitso far? Let’sgetintoabitmoredetailanddiscoverHOWthemagichappens. It’squitesimple.Allisyou needtodo,istosetthecorrectrulesinaparticularfile stored onthewebserver.Theserulessetthedatetodiscardoldcopiesandgetfreshcopies fromthe webserver. HOWWILLBROWSERCACHEEFFECT LOADSPEEDOFAWEBSITE? Whenauserclicksonalinkinthebrowser,anHTTPrequestgoestothewebserver browsertoallowfiledownload.Thebrowserthenstoresthefilesinthecachefora specifiedperiod. Thebrowserwill servethefilesimmediatelyinsteadofrequestingthewebserver. Letustakealookatanexamplethatwillhelpyouunderstandhowbrowser cachingcan beleveragedforbetterpagespeed. GTMetrixisaspecializedwebsiteperformanceanalysistool.Thebestdigitalmarketingcompaniesuseittotrackwebsitemetrics.AtypicalreportfromawebsiteanalysisperformedonGTMetrixwouldlooklike this Onthescreenshotyousee,thethirdrecommendationis“Leveragebrowsercaching”. Digitalmarketingexpertsknowthatthisrequirestheadditionof“ExpireHeaders”. HOWTOADDEXPIREHEADERS? TherearetwowaysinwhichExpiresHeaderscanbeaddedtoleverageabrowser’s caching ability. WecanchoosetoaddExpiresHeadersmanuallyorbyusinganappropriateplugin.Let’s findout howto do thisusingbothmethods. HOWTOADDEXPIREHEADERS?
ThesolutionpresentedherewillshowyouhowtoaddExpireHeadersonApacheand NGINXserversin4 easy steps. STEP1– LogintoC-Panelonyourhostingaccount. STEP2 –LocatetheFileManagericonashighlightedbelow.Clickonit. AfterclickingontheFileManagericonyoushouldbeinthefilesandfolderstructureof yourwebsite. STEP3 –Nowlocatethefolder“public_html”(highlightedbytheredbox&arrow)witha blueglobeicon onits side.Goaheadand clickonthat. STEP 4–Thepublic_htmlfolderstoresthe“.htaccess”file.Navigateyourpointertothe “.htaccess”fileandRIGHTCLICKonit.Whenyouarepresentedwithamenu,choose EDIT. Nowcomestheeasiest part. Justcopyandpastethelinesofcodedisplayed below. <IfModulemod_expires.c> ExpiresActiveOn # Images ExpiresByTypeimage/jpeg“accessplus1 year” ExpiresByTypeimage/gif“accessplus1year” ExpiresByTypeimage/png“accessplus1year” ExpiresByTypeimage/webp“accessplus1year” ExpiresByTypeimage/svg+xml“accessplus1year” ExpiresByType image/x-icon “accessplus 1year” # Video ExpiresByTypevideo/mp4“accessplus1 year”
ExpiresByTypevideo/mpeg“accessplus1 year” #CSS,JavaScript ExpiresByTypetext/css“accessplus1month” ExpiresByType text/javascript“access plus1month” ExpiresByTypeapplication/javascript“accessplus1month” # Others ExpiresByTypeapplication/pdf“accessplus1month” ExpiresByTypeapplication/x-shockwave-flash “accessplus1month” </IfModule> ADDINGEXPIREHEADERSINWORDPRESSBYUSING PLUGIN IfyouarenotcomfortablewitheditinganyfilesthenAddingExpireHeadersfrom .htaccessisnotbeadvisable.Anytypeofmistakeineditingcanrenderthewebsiteinaccessible. Luckilypluginsareavailable forWordPressusersto solvethisissue.Someofthehighly recommendedpluginsare: ADDEXPIREHEADERSPLUGIN Itwill: Reducepageloadtimebycaching browser Improveuserexperience Decreasethetotaldatasizeofthepage Ithasbothfreeandprofeatures. W3TOTALCACHE
WhenitcomestobrowsercachingW3TOTALCACHEpluginisanexcellentplugin available.Itsolvesmanywebpagecacheproblems.Italsooffersfilecompressionaswell aswebsitesecurity,andtraffic management. Itdoesalotmoreincludingallowingauser tominifyJavaScript,andthebestthingofallisthatitisafreeplugin.Let’shopeitstays thatway! WPROCKET WPRocketisalsoagreatplugin.Thatisifwouldliketogowithapremiumandcanafford it. Startingat49$peryearitoffersalot.Fromcachingandgziptocompression,lazyloading expiresheadersandawholelotmore.Youdon’tneedtoaccessanyfilesoradd, delete oreditasinglelineofcode.Thispluginwilldoeverythingfor youandkeepyourwebsiteintip-topshape. That’sit! Bookmarkthispageandcomebacktoitifyouneedarefresher.