Hyper Cache plugin – caching without problems. Setting up the Hyper Cache plugin for caching in WordPress Advanced cache php inclusion

Home / Brakes

Site in user browsers and reduce the load placed on the resource by the . Loading speed increases due to the fact that each time users are given a ready-made and generated page (taken from the cache) rather than a page generated from scratch. The load on the server is reduced by reducing number of http requests.

Caching is vital on almost all modern websites and blogs. This is due to the exponential increase in hosting load even with relatively low traffic. And if there are a lot of visitors when caching is turned off, then the site’s brains will literally boil (pages will take a very long time to open, the site will periodically “go down”, that is, fail).

Installing the Hyper Cache plugin

The WordPress engine has at least several plugins that allow you to enable caching. One of the most popular and easy to use is Hyper Cache plugin. You can download it from the official WordPress repository - wordpress.org (download), after using the site search.

In terms of downloading and installation, no problems should arise, since everything happens here according to the standard scheme (we pull out the folder with all the files from the archive and copy it to wp-content/plugins). After unzipping, go to the admin panel and look for Hyper Cache among all installed plugins. Click the “Activate” button. You also need to change the access rights to the folder with all wp-content/plugins plugins to 777 (read and write). The final stage of installation is editing the wp-config.php file. The following line of code should be entered here:

define('WP_CACHE', true).

This completes the installation. After activation, the plugin will immediately begin its work (it will cache blog pages).

Setting up Hyper Cache and reducing the load on the server

There are very few settings in Hyper Cache. First of all, go to the “Main” tab.

Here you can specify the cache lifetime (the time during which cached pages will be stored on the server). The optimal time is from several hours to several days (it all depends on the specifics of the site, the frequency of content updates, traffic and other factors). The more frequently the content is updated and the higher the traffic, the shorter the cache time should be. I usually specify 24 hours for our blog. You need to enable compression if you do not have it active.

Secondly, go to the “Exceptions” tab. Here you can specify the pages that should be cached. For example, you can disable caching:

  • for the home page,
  • for page 404,
  • for the comment feed,
  • for RSS feed,

All other items can be left as default.


hyper cache "Exceptions" tab

In the next tab “ Mobile” must be specified “ Operating mode” — > “Use standard cash”.


hyper cache "Mobile" tab

It is quite easy to check whether Hyper Cache is working or not. To do this, you need to access the blog from another browser or as an unregistered user. Look source code of this page (of course, unless you have disabled caching for it in the plugin settings). At the very end of the code there should be a line like this.

Hello visitors. I didn’t finish the last article a bit, there is also a lot of useful stuff there, be sure to read it. He told me how to do caching on the user’s side, or rather, so that the files are saved by the visitor in his browser, in simple words.

But if the visitor came for the first time, or likes to often clear the history and browser cache, what should you do then, then the previous post was useless. No, we can make a cache inside our server. A good and high-quality Hyper Cache plugin will help us with this. Our entire site will be saved in a special folder on the hosting and will be loaded from there, convenient, isn’t it?

Installing the plugin.

The plugin can be installed as standard, via a search in the WordPress panel itself (I won’t say anything here, everyone can install plugins). Well, that's it, let's move on. Now he will swear that you did not write his code in the configuration file (in my opinion, this is very cool, you make decisions, not the program), he will invite you to add your code to the wp-config.php file.

This file is located in the root of the site, don’t miss it, just open the public_html folder, and it’s there, download it for yourself.

Next, you need to open it with any editor and enter this code:

Define("WP_CACHE", true);

The hyper cache plugin itself suggests adding it after the line:

Define("WPLANG", "ru_RU");

But, for example, I didn’t have it, this problem may lead some beginners to a dead end, but in fact it can be inserted anywhere, up to this line in the wp-config.php file:

Define("WP_DEBUG", false);


Now we save everything and upload it back to the hosting. If you did it correctly, the line with the remark will disappear.

Setup.

Here we come to something delicious. There are many articles on the Internet about setting up this plugin, but they are all written about its old versions, which have nothing in common with the new one, so gentlemen, bloggers, update the data or delete it altogether, it has lost its relevance. Oh well.

Now let’s look at the home tab and the main hyper cache buttons, I’ll immediately give a screenshot.

Let's start with the line of main buttons, when you installed the plugin, it will make a copy of the site in its own folder.

  1. Delete all cache. Anything done and copied by the plugin will be immediately deleted. This is useful if you are making some global changes to your blog, such as changing the design, then this button will clear everything and copy new images to your cache.
  2. Cleaning archives and home. A very useful functionality that frantic bloggers who churn out 10 articles a day will need, just if the plugin doesn’t have time to cache the main page for you, in the sense of updating it, then click on this button, but we’ll talk about this below.
  3. Calculating cache size. A stupid gadget, the plugin simply informs you how much space a blog copy takes up in at the moment.
  4. Import settings. The point is even more useless than the last one. Never, hear me, never transfer settings from old versions of plugins, because old glitches and shortcomings can spread along with them.

Now you can go to the settings of the “Home” tab itself.

  1. Disable translations. The plugin has been partially translated into Russian, but if you want to wait for the release of the full Russified product, you can check the box here, although I don’t recommend it, since this will never happen, these are statistics, you shouldn’t wait for the weather by the sea.
  2. Cached pages will be valid for. Here you can set your cache storage period. I advise you to leave everything as is once a day (every 24 hours) and let it be updated.

    If you have written more than one article per day, but several, then do not expect that they will appear on the main page, because the main cache has not yet been updated, just click on the “Cleaning archives and home” button, and everything will immediately appear for you in the future.

  3. Enable compression. A rather controversial point, it activates compression in gzip format, that is, it packs the entire page into an archive and gives it to the user’s browser, which in turn unpacks it and displays it. But after wandering through many forums, I found out that this function may not work, and an empty entry is displayed to users, so we do not set this item. We will configure the compression itself in the next article, where everything will be a little more complicated, but more trouble-free.
  4. Enable on-the-fly compression. On-the-fly compression, if translated literally, I don’t see the point in enabling it. If the post is not cached for some reason, then it will do it in an instant, but it will take a wildly long time to load, it’s better to do it this way.
  5. When updated home page, the rest will be updated. A useless function, why should I clear the cache of recent entries if I clear the entire main page, complete nonsense, we leave everything at zero.
  6. When entries are edited. Here, in principle, you can put the first item clean archives (categories, tags, ..., but not the home) so that after editing an entry, it is immediately updated in the cache. But I didn’t install it, I don’t often update old entries, and my cache is set to update once a day (item 2 of this list), but see for yourself.
  7. When writing a comment. It’s also a controversial point, I’ll say right away that I didn’t put them, I’ll explain why. The post will be cached every time a comment is left, this will be a disaster for sites with high traffic and commenting, because with each comment it will be rewritten again, which is not good for speed and server processing. And for me, updating once every 24 hours will be enough, let everything go in such a cycle, leaving everything empty
  8. Cache folder. You can write your path to the files that the plugin will create, I left the field empty, let him write where he needs it.
  9. Further this function will be executed through. Nobody knows what it is and why, I don’t use this section.
  10. Allow browser caching. That is, we allow browsers on the user side to cache our site, we have already configured this in the previous article about .htaccess, and in order to avoid conflicts, it is better to turn it off, it won’t make things worse.
  11. HTTPS. If you have a secure connection, then you can still play around here, but leave everything as is.
  12. Use readfile(). Also, no one knows what it is, so we leave it turned off.
  13. Serves bots with expired pages. We don’t tick the box, it’s not needed.

Exceptions.

  1. Do not cache the home page. The main page is a very dynamic element of the blog; under no circumstances should it be cached; we do not check the box.
  2. Do not cache “page 404”. We don’t put it in the same way, there’s no reason to put it in memory.
  3. Do not cache the comment feed. I didn’t put it, let the comments be entered in the same way.
  4. Do not cache RSS comments feed. I haven’t turned it on and I don’t recommend it.
  5. Exclude the exact URI. Enter here the addresses that you want to exclude; it is useful if you are holding any relay races on the blog, when the entry must be constantly changing.
  6. (Starting with) URIs excluded. Same as the previous one, only here you can assign an exception for entire sections, for example headings.
  7. Exclude cookies. We exclude them on the user side.
  8. Devices (user) should be excluded. This section excludes devices for which cache is not enabled.
  9. Don’t serve cached pages to comment authors. Be sure to enable it if you have comment moderation enabled, otherwise the window saying “Comment is being reviewed” will not appear.
  10. Don't cache older pages. I think that this line is completely unnecessary, how can you not cache old posts, they contain the most important thing of the blog, although I think it’s suitable for news sites, but for the rest it’s evil.

Section “Mobile”.

  1. Operating mode. If you do not use a separate theme for mobile devices, then leave everything as usual here.
  2. Mobile theme. Based on the first section, we choose a topic, or leave it as it is.
  3. Mobile user agents. Here you can enter different OS, android, app and others.

In general, this tab is relevant if you have a separate theme for mobile devices, since I have everything on a responsive design, I didn’t touch anything, everything is by default.

I completely forgot, you can check the functionality of the plugin like this: initial setup let him do everything, wait a while, now enter any entry, while exiting WordPress or through another browser, and press the combination Cntrl + U, you will have a new tab where all the code is written, scroll to the end, and if everything works, then at the very bottom there will be something similar to this inscription.

Now you understand why, I didn’t want to do a review in the last post, it would have just been a big towel.

P.S. Thank you for your attention, I hope the article was useful and you configured everything correctly

Good afternoon, friends!

Today's article is dedicated to the Hyper Cache plugin, which implements page caching on a WordPress site and makes it work faster.

Moreover, the plugin has been updated and has become not very clear, in my opinion. It is imperative to clarify this issue and analyze its settings in detail. You can download the plugin from the official website.

I suggest you start by defining the concept of "caching" and explaining why it is so important for your site.

What is caching and why do you need Hyper Cache?

I'll try to tell you in simple words.

The fact is that our engines (WordPress, Joomla, etc.) initially generate their pages from PHP code. And our visitors are given ready-made HTML code. Now you see a page with all the text, pictures and other elements. This is an already generated page.

Each such generation is created when a visitor accesses the page. For example, I wrote in Google search some phrase and it showed me a return of 10 pages. I go to one of them and at this moment, the engine creates a request to the database to form HTML pages from PHP. After which I see the page I downloaded in its finished form.

Each such request creates a certain load on the blog database. Naturally, this is a certain job that takes up a resource. In our case, this is the page loading speed, i.e. loading time.

Imagine that you have 1000 visitors per day on your blog. Let’s say that 40-50 visitors visit the pages of your website in one unit of time. Thus, at any given moment, 40-50 queries are created to the database to generate the finished page.

Do you think the blog will slow down? The answer is obvious - yes! What if the attendance is much larger? Then the speed may drop significantly.

It's no secret that site loading speed is one of the factors that affects a site's position in search engines. If you take 2 absolutely identical sites, but the speed of one takes 1 second, and the second 2s, then the 1st site will be higher in position.

Therefore, you need to load the site as quickly as possible. The Hyper Cache plugin helps a lot with this.

What is his job?

When you make the first request to the database to generate a page, the plugin immediately creates a copy of the finished page and places it in its folder. The folder is located on the hosting.

Thus, there is no need to generate this page again each time. After a visitor accesses this page, the plugin will automatically give him a ready-made option.


As you can see, there is a folder with the name of the article, and inside the folder there is an index.html file. That is, an already generated page.

With high traffic, the plugin really saves blog resources. This is especially important if your hosting plan has load restrictions.

I hope that I clearly explained the importance of such a plugin on your site. I classified this plugin as . Now let's move on to its settings.

Installing the plugin

Easy installation of the plugin in this case you won't get by. It is necessary to touch the configuration file of our blog.

After installing and activating the plugin, you need to enable the caching function for it to work. Let's go to the plugin settings. After activating it, the corresponding “Hyper Cache” item appears in the “Settings” menu.

On the next page we will see the plugin settings, but we are interested in the warning at the top of the page.

The warning says that we must add a new line of code to the wp-config.php file:

define("WP_CACHE", true);

define ("WP_CACHE" , true ) ;

Let's do it. Open the wp-config.php file. It is located at the root of the site, that is, where all the folders and files of the engine are located. See the image below and you will understand everything.

I downloaded this file from my website folder directly from the hosting using FTP client FileZilla(). I’ll also upload it back later.

I open the file in the Notepad editor and paste the code provided above anywhere. For clarity, I’ll show you where I inserted it.

Let's go back to the plugin settings and try to simply refresh the page. If everything was done correctly, the message about the need to insert this code will disappear. All that remains is to Save settings to update the files.

I will show all settings in Russian. If you use English version When setting up, you can easily navigate by the images.

Main settings of the Hyper Cache plugin

On the settings page, the first thing you want to pay attention to is the buttons for managing the cache.

Briefly about each of the buttons.

  • Delete entire cache - the button is used to clear the entire cache. After clicking it, all saved pages in the cache will be deleted. The collection of pages into the cache will begin again;
  • Cleaning archives and home - button to remove only pages from the cache home page website and section pages with archives;
  • Calculating the cache size - if you want to find out the total number of pages that are currently in the cache, then click on the button and the plugin will calculate everything. At the moment the size of my entire cache is 235kb;

The size is very small as there are only 10 articles on the blog.

  • Import settings - as far as I understand, the button is used to import settings from old version plugin. I couldn't use this button.

Now look at the main Hyper Cache settings.

First I will show an image of the settings, then I will describe them.

  • Disable translation - this checkbox is responsible for translating the plugin into Russian. Since the plugin itself is English, then it is quite difficult for a beginner to understand it. By enabling this setting, you will make a description of all plugin functions in the settings in English, canceling the translation with which it is installed by default;
  • Cached pages will be valid for - specify the period during which the saved pages will be stored in the cache. If you set it to 0, then the pages will always be in the cache. If you update the content of your pages very often, then set this value lower, since visitors will not see these changes due to the fact that previously saved options located in the folder with cached pages will be displayed. I set the value to 300 hours to keep pages in the cache longer;
  • Enable compression - if you want to compress your pages, then check this box. I use compression, so I activated the setting;
  • When the home is refreshed, refresh even the - in this setting we can set how many recent entries will be cleared from the cache when the home page is refreshed. And on blogs, the main page is updated when posts are added, since their announcements are displayed on the main page. And this is also a page update. I leave the default value;
  • When a post receives a comment - enabling this setting The cache of archive pages, categories and tags will be updated (the “clean archives” checkbox), as well as the main page will be updated (the “clean the home” checkbox) when comments are added to the article. I think that these settings do not need to be enabled;
  • When a post is edited - the same as the previous setting, only the cache is updated when the page is edited;
  • Cache folders - you can enter your own path for storing cached pages. I'm quite happy with the standard directory;
  • Further, this function will be performed in - the value of this setting is set to automatic. We can’t change anything;
  • Allowing browser caching - to be honest, I still don’t fully understand this setting. If anyone knows what it is about, write in the comments. The developer does not use this setting. Let's listen to his opinion and also will not include it;
  • HTTPS - which caching option to use for the https protocol. I use the "cache separately" option;
  • Use readfile - the setting adds some kind of php readfile function. To be honest, I didn’t understand what its meaning was;
  • Serve expired pages to bots - whether to serve expired pages to bots that visit your site. Left it disabled;
  • Tidy - the same as the previous one. After updating the plugin, the setting was removed.

In fact, there are questions with the latest settings, since they appeared after a recent plugin update and I don’t know exactly what the use is. But I left everything as described above.

Exception settings

  • Do not cache the main page - if we have a regular blog where new posts are constantly being added and their announcements are published on the main page, then we enable this setting so that the main page is not cached. On the main page, all changes should be displayed in real time;
  • Don't cache the 404 page - There is no particular need to cache the 404 page. Therefore, we also put a checkbox;
  • Do not cache comments feed - I did not enable this setting;
  • Do not cache RSS comments feed - also not enabled;
  • Exact URL exclusion - if you want to exclude some pages from caching, you can enter their full addresses. It can be helpful if there is some article in which you constantly change something. For example, you update the results of the competition in real time every day;
  • (Starting with) exclude URL - this setting is useful if you want to prohibit a certain set of pages from caching, for example, from one category. Then enter part of the address here, starting with the name of the category, and all pages that begin with the name of this category will not be cached;
  • Excluding cookies is a more professional setting. Allows you to exclude page caching using cookies;
  • Exclude devices (user) - if a visitor accesses the site through some agent, then by specifying its name in this setting, caching will not occur for him;
  • Don't serve cached pages to comment authors - when you leave a comment on a blog, it usually awaits verification. You are always notified about this. For it to actually be displayed, this setting must be enabled;


  • Do not cache older pages - I think this setting is useless, since the older the page, the higher its position in search engines and the more visitors it should visit. On the contrary, such pages must be cached. Therefore, I do not touch this setting. You can set your age for pages that don't need to be cached.

Mobile Settings

  • Operating mode - I myself use the standard mode. You can select the "cache separately" option for separate caching. May be required if you have different content for mobile devices;
  • Mobile theme - select the design theme that you want to cache or leave the standard option “Use the active blog theme”, with which the plugin will determine the active theme;
  • Mobile user agents - this field contains the main ones mobile devices, from which sites are visited.

With this we have completed all the settings. Do not forget to save all the operations performed.

We can check the operation of the plugin very simply. It is enough to go through another browser to any page of your site. This page must already be in the cache. Then open its source code (ctrl+u) and at the very bottom of the page there will be a line that is output by the plugin.


If such a line exists, then this page is already in the cache and the plugin is working successfully.

By tradition, I have prepared a special video tutorial on setting up the hyper cache plugin. Let's look below.

After this, I hope that everything has become more than clear to you.

If you have any questions, write them in the comments. I will answer everything. Also write ideas for reviewing new plugins and other features. I’ll take note of everything and will definitely do it in the near future.

This is where I end this article. And remember: "Fast blog - convenient blog". Therefore, make his work quick.

See you soon.

Best regards, Konstantin Khmelev.

For high site ranking from the outside search engines The loading speed of website pages is important. The faster the user receives content, the less likely it is that he will leave the loading page. Both hosting providers and CDN networks often participate in the struggle for website loading speed. But it is much easier to improve the performance of the project using special plugins. Many caching extensions have been developed for the WordPress platform, among which Hyper Cache stands out for its performance and easy configuration. Unlike “hypercache,” it does not turn the site into pure static HTML, but allows both JS scripts and AJAX to work. Why is this plugin so good and how to configure it correctly?

Hyper Cache and Super Cache– There are 2 of the most popular caching plugins and users are wondering which one is better to choose. I must say that once I had problems with the operation of Super Cache on one of the sites - it stopped working due to some changed hosting settings. Instead, Hypercache was installed. At that time, I monitored the load on the hosting for this site and discovered that after installing hypercache, the load on the hosting became noticeably less, that is, hyper cache worked more efficiently. However, completely opposite points of view can be read. Most likely for different situations(site and hosting configurations), one or another plugin may be more effective.

Installing the Hyper Cache plugin is no different from installing other extensions. Installation is possible in two different ways:

  • uploading the unpacked archive with the plugin via FTP and subsequent activation via the console;
  • installing the extension through the plugin control panel.

When finished, don’t forget to activate the extension in the “Plugins” tab. Managing the “hypercache” settings is located along the path “Settings” >> “Hyper Cache”.

One way or another, at the end you get a plugin almost ready for caching. Before caching the first page, .Hyper Cache requires the owner to look into the blog config file and enter there small code. This procedure takes a couple of minutes and does not require special programming skills.

Open the root folder of the blog on your hosting using the file manager and find the wp-config.php file. Click “Edit” and in the new window after the line define (‘WP_DEBUG’, false); enter the code define (“WP_CACHE”, true), as written in the screenshot above in the first line.

Save the file and try updating the plugin settings. If the “hypercache” still complains, then take a closer look at what you specified in the config file. You can also make changes to wp-config.php via FTP by editing the file in Notepad, for example, in Notepad++.

You can find the plugin in the WP depositories – https://wordpress.org/plugins/hyper-cache/. However, it should not be confused with the Hyper Cache Extended extension; these are two completely different plugins.

Plugin setup

The hypercache settings consist of four sections. Basic settings are stored in the “Main” section, and settings for mobile platforms in the “Mobile” subsection. CDN is responsible for working with CDN networks, and the “Exceptions” subsection speaks for itself. If the plugin appears in front of you in the English version, then you need to uncheck the “Disable translations” item and click “Save” at the bottom. The extension has not yet been fully translated, but it is much easier to understand the settings when they are at least partially written in a language understandable to the user.

In addition to the settings themselves, the top block contains four buttons for “quick” access to the plugin’s functions:

  • delete all cache – clears the entire cache stored on the server. A very useful feature when changing the design or making any changes to the template.
  • cleaning archives and home – when this option is activated, only the home page and archives are affected. However, cached pages and posts remain in the blog cache.
  • calculating the cache size - if your hosting does not have enough space, then by clicking on this button, you can find out how much cache copies of blog pages take up on disk.
  • import settings – the Hyper Cache plugin has gone through several reincarnations, as a result of which the developers allowed owners of older versions of the extension to import old settings into new version"hypercache".

Now let’s go through the settings that you should definitely activate. In the “Main” section, the first thing you need to do is specify the cache lifetime. If you want pages to be cached forever, then enter the number 0. In otherwise enter the lifetime in seconds. Let us remember that an hour is 3600 seconds. It's also worth noting the "Enable Compression" option for those who don't use Gzip for compression. The rest of the home page settings are optional, but you can experiment with them if you wish.

In the “Exceptions” section, you can prevent caching of the main page, as well as pages with the “404” error, by checking the appropriate boxes. If it is important for you that any blog page does not end up in the cache, then activate the “Exact URI address to exclude” option by checking it, and enter the full URLs of the pages you need.

If desired, you can also disable caching for individual browsers and platforms, as well as for pages older than a certain age. For example, by registering the user agent “Opera”, you will disable caching for the browser of the same name.

If your blog is still not equipped with a responsive theme, and you still use a special plugin to switch blog themes, then the “Operation Mode” item is created for you. Specify “Cache separately” and click “Save”. At the same time, do not forget to select the appropriate template in the “Mobile Theme” item.

Do you use CDN networks to speed up website loading? “Hypercache” will help you with this too, because you just need to activate the setting and enter the CDN URL in the appropriate box.

This completes the plugin setup. It should be noted that after each change of settings, you need to click on the “Save” button and then reset the entire blog cache so that the pages are reformatted in the cache.

  • htaccess caching saves the content of a web page to local computer when the user visits it;
  • Using the Browser Cache – The webmaster instructs browsers how to treat resources.

When the browser renders a web page, it must load the logo, CSS file, and other resources:


The browser cache “remembers” resources that the browser has already downloaded. When a visitor goes to another page on the site, logo, CSS files, etc. shouldn't be downloaded again because the browser has already "remembered" them (saved them). This is the reason why the web page takes longer to load on your first visit than on repeat visits.

When you use caching, the web page files will be stored in the browser cache. Pages will load much faster on repeat visits. It will also happen with other pages that use the same resources.

How to enable browser caching

  • Modify resource request headers to use caching;
  • Optimize your caching strategy.

Changing request headers

For most people, the only way to cache a site's htaccess is to add code to the .htaccess file on the web server.

The .htaccess file controls many important settings for your website.

Browser caching via .htaccess file

The code below tells the browser what to cache and how long to “remember” it. It should be added to the beginning of the .htaccess file:

## EXPIRES CACHING ## ExpiresActive On ExpiresByType image/jpg "access 1 year" ExpiresByType image/jpeg "access 1 year" ExpiresByType image/gif "access 1 year" ExpiresByType image/png "access 1 year" ExpiresByType text/css "access 1 month" ExpiresByType text/ html "access 1 month" ExpiresByType application/pdf "access 1 month" ExpiresByType text/x-javascript "access 1 month" ExpiresByType application/x-shockwave-flash "access 1 month" ExpiresByType image/x-icon "access 1 year" ExpiresDefault "access 1 month"## EXPIRES CACHING ##

Save the .htaccess file and then refresh the web page.

How to set cache time for different file types

The above code specifies time intervals. For example, 1 year (1 year) or 1 month (1 month). They are related to file types. The above code states that .jpg files (images) should be cached for a year.

If you wanted to change this so that JPG images would also be cached for a month, then you would simply replace "1 year" with "1 month". The above htaccess caching values ​​are optimal for most web pages.

Alternative caching method for .htaccess

The method described above is called " Expires", it helps most beginners with caching. Once you get comfortable with caching, you can try another caching method called Cache-Control, which gives you more options.

It's possible that the Expires method won't work on your server, in which case you might want to try using Cache-Control.

Cache-Control

This method allows you to gain more control over page caching in the browser, but many people find it easier to specify all the settings once.

Example usage in a .htaccess file:

#1 Month for most static assets Header set Cache-Control "max-age=2592000, public"

The above code sets the Cache-Control header depending on the file type.

How does Cache-Control work?

Consider the above line of caching code in the htaccess browser:

#1 Month for most static assets

This line is just a note. The .htaccess file ignores lines starting with the # character. This note is recommended because you may have several different data sets as your file caching solution:

The line mentioned above says that, " if the file is one of these types, then we will do something with it...»

The most important thing about this line is that it lists various types files ( CSS, JS, JPEG, PNG etc. ) and that caching instructions should be applied to these file types. For example, if you don't want JPG files to be cached for a specified period of time, you can remove " JPG". If you want to add HTML, then you need to indicate in this line “ HTML«:

Header set Cache-Control "max-age=2592000, public"

The line mentioned above sets the actual headers and values:

  • Part " Header set Cache-Control» — sets the title;
  • Variable " max-age=2592000"—indicates how long the caching process will take (in seconds). In this case, we cache for one month (2592000) seconds;
  • Part " public» reports that it is publicly available.

© 2024 ermake.ru -- About PC repair - Information portal