Using mod_expires, you can tell visiting browsers to hold on to certain files longer (likes images, which are rarely changed). ss. It should be added to the top of ss file. ## EXPIRES CACHING ## mod_expires.c> ExpiresActive On ExpiresByType. htaccess mod_expires / mod_cache / mod_deflate / mod_headers ss.
|Published (Last):||16 August 2018|
|PDF File Size:||18.67 Mb|
|ePub File Size:||20.97 Mb|
|Price:||Free* [*Free Regsitration Required]|
When a web browser displays your webpage it has to load several things expiresbytypr your logo, your CSS file, and other resources. What browser caching does is “remember” the resources that the browser has already loaded. When a visitor goes to another page on your website your logo, CSS files, etc.
This is the reason that the first view of a web page takes longer than repeat visits. When you leverage browser caching, your webpage files will get stored in the browser cache. Your expidesbytype will load much faster for repeat visitors and so will other pages that share those same resources.
If you have tested your webpage for speed and found out that you need to leverage browser caching, here is how you do it. For most people, the way to enable caching is to add some code htacdess a file called.
This means going to the file manager or wherever you go to add or upload files on your webhost.
If you are not familiar with the. The code below tells browsers what to expireebytype and how long to “remember” it. It should be added to the top of your. You can see in the above code that there are time periods like “1 year” or “1 month”.
3 Simple .htaccess Rules For Better Website Performace
These are associated with file types, as an example the above code states that a. If you want to change that and say you want your jpg images cached for a month you would simply replace “1 year” with “1 month”. The values above are pretty optimized for most webpages and htacdess.
The above method is called “Expires” and it works for most people using. After you are more comfortable with caching, you may want to try Cache-Control, another method of caching which gives us more options.
It is also possible the expires method did not work for your server, in that case you may want to try to use Cache-Control. Hatccess have made a more complete guide to Cache-Control here.
How to Add mod_expires to your .htaccess | InMotion Hosting
Cache-Control allows us to have a bit more control of our browser caching and many people find it easier to use once setup. The above line is just a note. It does not do anything except notate what we are doing. This note is recommended as you may have several expiresbytypw sets of these as your caching solution grows. The above line is saying that “if the file is one of these types, then we will do something to it The important part of this line is to notice that there are different types of files listed css, js, jpeg, png, etc.
As an example, if you did not want your jpg files to be cached for this amount of time you could delete “jpg” from this line or if you wanted to add html to this you could just add “html” to this line.
How to leverage browser caching of your website or blog
If you list your html and images to be cached for one year expitesbytype some other long time period, remember that this can mean if you make a change to your pages they may not be seen by all users. This is because the users will look to cached files rather than the live ones.
If you have file that you tweak occasionally example – a CSS file you can expirebytype the cache issue by using URL fingerprinting. URL fingerprinting Getting a fresh not cached file resource is possible by having a unique name.
An example would be if our css file was named “main. This is useful for files that change occasionally. It is redundant to specify both Expires and Cache-Control: What hraccess browser caching?
Browser caching stores webpage resource files on a local computer when a user visits a webpage.