{"id":1172,"date":"2020-06-27T18:53:00","date_gmt":"2020-06-28T01:53:00","guid":{"rendered":"https:\/\/SUMMALAI.COM\/?p=1172"},"modified":"2020-06-28T21:25:41","modified_gmt":"2020-06-29T04:25:41","slug":"configure-apache-2-to-control-browser-caching","status":"publish","type":"post","link":"https:\/\/SUMMALAI.COM\/?p=1172","title":{"rendered":"Configure Apache 2 to Control Browser Caching"},"content":{"rendered":"\n<p>Original: https:\/\/www.liquidweb.com\/kb\/how-to-configure-apache-2-to-control-browser-caching\/<\/p>\n\n\n\n<p>by\u00a0Jason Potter\u00a0|\u00a0Updated:\u00a0June 4, 2020<br>Reading Time:\u00a09\u00a0minutes<\/p>\n\n\n\n<p>Today we are configuring browser caching control on common Apache 2\u00a0Dedicated servers\u00a0or\u00a0VPS servers. Caching is a great tool to reduce server resource consumption, bandwidth utilization and provide a faster end-user experience to visitors. To get familiar with caching concepts, simply review our \u2018<em>What is Caching<\/em>?\u2019 tutorial.<\/p>\n\n\n\n<p><strong>Preflight Check<\/strong><\/p>\n\n\n\n<p>This article covers all Apache 2 servers running the mod_expires and mod_headers Apache modules. This includes, but is not limited to, both traditional Dedicated Servers and Cloud VPS servers running a number of different Linux distributions:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Core-managed CentOS 7* Servers<\/li><li>Core-managed CentOS 6* Servers<\/li><li>Fully managed CentOS 7 cPanel Servers<\/li><li>Fully managed CentOS 6 cPanel Servers<\/li><li>Fully managed CentOS 7 Plesk Onyx 17 Linux Servers<\/li><\/ul>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>Self-managed servers running a similar Linux distribution can take advantage of this article. However, instructions are not specifically provided for Self-managed configurations.<\/p>\n\n\n\n<p>The article assumes familiarity with the following basic system administration concepts:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>SSH Connections and basic navigation of the standard\u00a0Linux command-line shell environment<\/li><li>Opening, Editing and Saving files in a chosen system editor (i.e.\u00a0Vim, Nano, etc\u2026).<\/li><li>Some familiarity with command-line piping via\u00a0Linux I\/O Redirection<\/li><\/ul>\n\n\n\n<p><strong>Verify Modules<\/strong><\/p>\n\n\n\n<p>Our servers generally include both the mod_expires and mod_headers modules needed for browser cache control. However, before we configure the directives, we must first ensure the modules are installed and Apache 2 is ready to accept the directives. Verification is simple. We will be using the&nbsp;<em>apachectl -M<\/em>&nbsp;command to list the installed Apache modules while piping the output through the&nbsp;<em>grep module_name<\/em>&nbsp;command to filter the results down to showing only modules with the provided module_name, likes so:<\/p>\n\n\n\n<p>Verifying&nbsp;<strong>mod_headers<\/strong>&nbsp;(also known as Headers_module) by copying &amp; pasting the following command.<\/p>\n\n\n\n<p>apachectl -M | grep header<\/p>\n\n\n\n<p>\u2026 will return:<\/p>\n\n\n\n<p>headers_module (shared)<\/p>\n\n\n\n<p>Verifying&nbsp;<strong>mod_expires<\/strong>&nbsp;(also known as expires module) by copying and pasting the following command.<\/p>\n\n\n\n<p>apachectl -M | grep expires<\/p>\n\n\n\n<p>\u2026 will return:<\/p>\n\n\n\n<p>expires_module (shared)<\/p>\n\n\n\n<p>These modules must be present in the output when running the command. If they do not show up in the output, it will simply be blank, which indicates the modules are not installed. If the modules are missing then we will need to install them before we can continue.<\/p>\n\n\n\n<p><strong>Configuration Directives<\/strong><\/p>\n\n\n\n<p>We can use the following example of a generic configuration that serves to reduce the strain on server resources by prolonging the cache duration of common static files. These types of files typically do not change between visits. So, they do not need to be downloaded on every visit. Modern browsers are equipped to accept instructions from web servers that provide suggestions for how long content should be cached. This example works well for most sites. However, you may need to add\/remove file types or adjust lifespan as needed for your particular content.<\/p>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<p>Explanation of Each Directive<\/p>\n\n\n\n<p>These are opening tags and will only process directives between these if the module, mod_expires, is installed on the server.<\/p>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt; &#8230; &lt;\/IfModule&gt;<\/p>\n\n\n\n<p>Download all files only if the cache has not been accessed in more than 2 days.<\/p>\n\n\n\n<p>ExpiresDefault &#8220;access plus 2 days&#8221;<br>Download files only if the cached file has not been accessed in more than 1 month. This covers jpg, jpeg, gif, png, css, javascript, flash, ico, and x-icon file types.<\/p>\n\n\n\n<p>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<\/p>\n\n\n\n<p>Download files only if the cached copy hasn\u2019t been accessed in 10 minutes.<\/p>\n\n\n\n<p>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<\/p>\n\n\n\n<p>You can find a more robust explanation of these directives and all that expires_module offers in the&nbsp;<a href=\"http:\/\/httpd.apache.org\/docs\/current\/mod\/mod_expires.html\">Apache mod_expires Online Docs<\/a>.<\/p>\n\n\n\n<p><strong>Implementation<\/strong><\/p>\n\n\n\n<p>Now that we have an understanding of how these directives can be configured, we need to decide on our method of implementation. There are generally two methods of implementation for these directives. We classify these as either Portable or Include Methods.<\/p>\n\n\n\n<p>Portable Method<\/p>\n\n\n\n<p>The Portable Method uses .htaccess files to manage which directories are affected by the mod_expires configuration we are settings. These are handled like any other .htaccess file changes.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>SSH\/FTP to the server<\/li><li>Locate the directory which needs browser caching enabled.<\/li><li>Modify the .htaccess file in that directory or create one if there is not one already.<\/li><li>Add the needed directives from the&nbsp;<strong>Configuration Directives<\/strong>&nbsp;section above.<\/li><li>Save the changes to the file.<\/li><li>Done.<\/li><\/ol>\n\n\n\n<p>There is a small bottleneck warning associated with&nbsp;.htaccess&nbsp;files. This caution is not specific to mod_expires and is an overall Apache alert including&nbsp;.htaccess&nbsp;files in general. In order for&nbsp;.htaccess&nbsp;files to work, Apache must scan every directory leading up to a targeted file looking for and applying any&nbsp;.htaccess&nbsp;files it finds along the way. This can create an I\/O bottleneck on some server configurations. We recommend using the Include Method on all Cloud VPS Servers to avoid this type of problem.<\/p>\n\n\n\n<p>Include Method<\/p>\n\n\n\n<p>In contrast to the Portable Method, the Include Method takes advantage of the Apache includes a system. Apache only reads include files at startup so this prevents the I\/O Bottleneck discussed above in the Portable Method section.<\/p>\n\n\n\n<p>There are generally two ways to use the Include Method:\u00a0<strong>Globally\u00a0<\/strong>or\u00a0<strong>Per Website<\/strong>. Either method requires locating and modifying the correct include files on the server. The correct files to modify is dependent on both distribution and server management software. We will discuss the correct locations for both methods on the various Liquid Web CentOS servers we support and listed in the\u00a0<strong>Preflight Check<\/strong>\u00a0section above.<\/p>\n\n\n\n<p>Global Includes<\/p>\n\n\n\n<p>Applying the mod_expires directives globally is straight forward. It will have the effect of enabling the desired directives over the entire server, affecting every site running through Apache.<\/p>\n\n\n\n<p><strong>Core-managed CentOS 6 &amp; 7 Servers<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create a file named&nbsp;<em>expires.conf<\/em>in<em>&nbsp;\/etc\/httpd\/conf.d\/ by typing in the following command:<\/em><\/li><\/ol>\n\n\n\n<p>vim \/etc\/httpd\/conf.d\/expire.conf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Add the necessary directives to the file and save the changes.<br>The file should look like the following:<\/li><\/ol>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>To finish, reload Apache for the server to see the changes:<\/li><\/ol>\n\n\n\n<p>Service httpd reload<\/p>\n\n\n\n<p><strong>Fully managed CentOS 6 &amp; 7 cPanel Servers<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create file name&nbsp;pre_virtualhost_global.conf&nbsp;&nbsp;in&nbsp;\/usr\/local\/apache\/conf\/includes\/&nbsp;if it does not already exist.<\/li><\/ol>\n\n\n\n<p>vim \/usr\/local\/apache\/conf\/includes\/pre_virtualhost_global.conf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Add the necessary directives to the bottom of the file and save the changes.<br>Your file may contain additional directives in this file, but the bottom should look like this:<br><\/li><\/ol>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Restart Apache Service:<\/li><\/ol>\n\n\n\n<p>\/scripts\/restartsrv_apache<\/p>\n\n\n\n<p>If Running EasyApache 4: Restart Apache PHP-FPM Service<\/p>\n\n\n\n<p>\/scripts\/restartsrv_apache_php_fpm<\/p>\n\n\n\n<p><strong>Fully managed CentOS 7 Plesk Onyx 17 Linux Servers<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create file name&nbsp;<em>expires.conf<\/em>in&nbsp;<em>\/etc\/httpd\/conf.d\/<\/em><\/li><\/ol>\n\n\n\n<p>vim&nbsp;\/etc\/httpd\/conf.d\/expire.conf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Add the necessary directives to the file and save the changes.<br>The file should look like the following:<\/li><\/ol>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Restart Apache Service:<\/li><\/ol>\n\n\n\n<p>Service httpd restart<\/p>\n\n\n\n<p>Per Website Includes<\/p>\n\n\n\n<p>We can also use Apache includes on a per virtual host level to enable browser caching on an individual website basis. We\u2019ll go over how to configure these on our CentOS systems below.<\/p>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>Each website has&nbsp;<em>two<\/em>&nbsp;virtual hosts, one for HTTP (port 80) connections and another for HTTPS (port 443) connections. Each virtual host is independent of one another. Adding a change to the HTTP virtual host will not automatically apply to the HTTPS virtual host and vice versa.<\/p>\n\n\n\n<p><strong>Core-managed CentOS 6 &amp; 7 Servers<\/strong><\/p>\n\n\n\n<p>The exact method of site management on Core-managed servers is left up to the server owner. This can vary dramatically depending on the person. We will use the default SSL site configuration file as an example on how to configure the Per Website includes for browser caching. Once you locate the necessary site\u2019s configuration file, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Locate and Open the configuration file for the site being modified.&nbsp;<\/li><\/ol>\n\n\n\n<p>vim \/etc\/httpd\/conf.d\/ssl.conf<br><br>2.&nbsp; Locate the Virtual Host line for the site within its config file.&nbsp; A Virtual Host Stanza looks like the following example:<\/p>\n\n\n\n<p>&lt;VirtualHost _default_:443&gt;<br>\u2026<br>&lt;\/VirtualHost<br><br>3. Apply the needed mod_expires directives between the virtual host lines.<br>The results should look similar to the following example:<\/p>\n\n\n\n<p>&lt;VirtualHost _default_:443&gt;<br>\u2026<br>&nbsp;&nbsp;&nbsp;&lt;IfModule mod_expires.c&gt;<br>&nbsp;&nbsp;&nbsp;# Turn on the module.<br>&nbsp;&nbsp;&nbsp;ExpiresActive on<br>&nbsp;&nbsp;&nbsp;# Set the default expiry times.<br>&nbsp;&nbsp;&nbsp;ExpiresDefault &#8220;access plus 2 days&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>&nbsp;&nbsp;&nbsp;ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&nbsp;&nbsp;&nbsp;&lt;\/IfModule&gt;<br>\u2026<br>&lt;\/VirtualHost&gt;<br>4. Restart The Apache Service<\/p>\n\n\n\n<p>service httpd restart<\/p>\n\n\n\n<p><strong>Fully managed CentOS 6 &amp; 7 cPanel Servers<\/strong><\/p>\n\n\n\n<p>cPanel provides a rich template system that can be used to modify Apache behavior as needed. There is a specific directory structure needed to ensure our modifications persist through updates, upgrades, and restarts. This system works the same way on both EasyApache 3 and EasyApache 4 systems.<\/p>\n\n\n\n<p>Each site can handle its set of custom includes files. These need to be located in the following locations:<\/p>\n\n\n\n<p><br>HTTP Virtual Hosts:<br>\/etc\/apache2\/conf.d\/userdata\/std\/2_4\/&lt;USER&gt;\/&lt;DOMAIN&gt;\/&lt;INCLUDENAME&gt;.conf<\/p>\n\n\n\n<p><br>HTTPS Virtual Hosts:<br>\/etc\/apache2\/conf.d\/userdata\/ssl\/2_4\/&lt;USER&gt;\/&lt;DOMAIN&gt;\/&lt;INCLUDENAME&gt;.conf<\/p>\n\n\n\n<p>There are three variables in the path above that need to be reconciled:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>&lt;USER&gt;&nbsp;replaced by the necessary account\u2019s username.<\/li><li>&lt;DOMAIN&gt;&nbsp;replaced by the fully qualified domain.tld name of the site. (minus the www. prefix)<\/li><li>&lt;INCLUDENAME&gt;&nbsp;replace by the name of the include file. This should reflect the includes purpose. E.G. expires.conf<\/li><\/ul>\n\n\n\n<ol class=\"wp-block-list\"><li>These&nbsp;directories do not exist by default and will need to be created. Once you know the details this can be done easily with the&nbsp;mkdir -p&nbsp;command like so:<\/li><\/ol>\n\n\n\n<p>HTTP Virtual Host:<\/p>\n\n\n\n<p>mkdir -p \/etc\/apache2\/conf.d\/userdata\/std\/2_4\/myuser\/example.com\/<\/p>\n\n\n\n<p>HTTPS Virtual Host:<\/p>\n\n\n\n<p>mkdir -p \/etc\/apache2\/conf.d\/userdata\/ssl\/2_4\/myuser\/example.com\/<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>After the directories are created, we can now create our include files, calling it expires.conf.<br>HTTP Virtual Host:<\/li><\/ol>\n\n\n\n<p>vim \/etc\/apache2\/conf.d\/userdata\/std\/2_4\/myuser\/example.com\/expires.conf<\/p>\n\n\n\n<p>HTTPS Virtual Host:<br>vim \/etc\/apache2\/conf.d\/userdata\/ssl\/2_4\/myuser\/example.com\/expires.conf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Add the necessary mod_expires directives to both expires.conf files. They should look similar to this when complete:<\/li><\/ol>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\"><li>Now we will need to have cPanel rebuild the Apache configuration to apply the new includes.<\/li><\/ol>\n\n\n\n<p>\/usr\/local\/cpanel\/scripts\/rebuildhttpdconf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\"><li>Restart Apache to update the running configuration:<br>\/usr\/local\/cpanel\/scripts\/restartsrv_apache<\/li><li>If running EasyApache 4, Restart Apache PHP-FPM service as well:<br>\/usr\/local\/cpanel\/scripts\/restartsrv_apache_php_fpm<\/li><\/ol>\n\n\n\n<p>There are additional methods for handling virtual hosts in cPanel. Applying includes to all hosts or all HTTPS hosts or even all hosts by one user. For a much more in-depth explanation of the cPanel Virtual Host Include system,\u00a0visit\u00a0the Official cPanel Online Docs.<\/p>\n\n\n\n<p><strong>Fully managed CentOS 7 Plesk Onyx 17 Linux Servers<\/strong><\/p>\n\n\n\n<p>Plesk provides a robust include and template system for modification of virtual host entries on an individual virtual host basis. These are done in the following files:<\/p>\n\n\n\n<p>Note:<\/p>\n\n\n\n<p>We will need to replace example.com with your domain name (minus www. prefix).<br>\/var\/www\/vhosts\/system\/example.com\/conf\/vhost_ssl.conf<\/p>\n\n\n\n<p>The directory structure here should already exist. However, these vhost.conf and vhost_ssl.conf files do not exist by default and will need to be created.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Create the needed include files:<br>HTTP Virtual Host:<\/li><\/ol>\n\n\n\n<p>touch \/var\/www\/vhosts\/system\/example.com\/conf\/vhost.conf<\/p>\n\n\n\n<p>HTTPS Virtual Host:<br>touch \/var\/www\/vhosts\/system\/example.com\/conf\/vhost_ssl.conf<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\"><li>Modify both vhost.conf and vhost_ssl.conf applying the necessary mod_expires directives. When finish each file should look similar to the following:<\/li><\/ol>\n\n\n\n<p>&lt;IfModule mod_expires.c&gt;<br># Turn on the module.<br>ExpiresActive on<br># Set the default expiry times.<br>ExpiresDefault &#8220;access plus 2 days&#8221;<br>ExpiresByType image\/jpg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/gif &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/jpeg &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/png &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/javascript &#8220;access plus 1 month&#8221;<br>ExpiresByType application\/x-shockwave-flash &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/css &#8220;now plus 1 month&#8221;<br>ExpiresByType image\/ico &#8220;access plus 1 month&#8221;<br>ExpiresByType image\/x-icon &#8220;access plus 1 month&#8221;<br>ExpiresByType text\/html &#8220;access plus 600 seconds&#8221;<br>&lt;\/IfModule&gt;<\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\"><li>Have Plesk rebuild the configuration for the site in question.<br>\/usr\/local\/psa\/admin\/sbin\/httpdmng &#8211;reconfigure-domain example.com<\/li><li>Restart Apache Service:<br>service httpd restart<\/li><\/ol>\n\n\n\n<p>The Plesk templates and includes systems are very robust and permits the integration of many other common Apache directives. Visit the&nbsp;<a href=\"https:\/\/docs.plesk.com\/en-US\/onyx\/advanced-administration-guide-linux\/virtual-hosts-configuration\/virtual-hosts-and-hosting-types\/virtual-host-configuration-files.72064\/\">Plesk Onyx Online Documentation<\/a>&nbsp;to learn more about leveraging its capabilities.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Original: https:\/\/www.liquidweb.com\/kb\/how-to-configure-apache-2-to-control-browser-caching\/ by\u00a0Jason Potter\u00a0|\u00a0Updated:\u00a0June 4, 2020Reading Time:\u00a09\u00a0minutes Today we are configuring browser caching control on common Apache 2\u00a0Dedicated servers\u00a0or\u00a0VPS servers. Caching is a great tool to reduce server resource consumption, bandwidth utilization and provide a faster end-user experience to visitors. To get familiar with caching concepts, simply review our \u2018What is Caching?\u2019 tutorial. Preflight Check <a class=\"read-more\" href=\"https:\/\/SUMMALAI.COM\/?p=1172\">Read More<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[104,5],"tags":[],"class_list":["post-1172","post","type-post","status-publish","format-standard","hentry","category-apache","category-linux"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/1172","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1172"}],"version-history":[{"count":0,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=\/wp\/v2\/posts\/1172\/revisions"}],"wp:attachment":[{"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1172"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1172"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/SUMMALAI.COM\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}