Self-setting proxy Server cache picture Save Internet traffic _ server Other

Source: Internet
Author: User
You can actually install an Apache HTTP server on your computer, make it into a forward proxy, and then use the caching capabilities to save traffic.

How to configure forward proxy here is not much to say, on the internet to catch a lot. Here, there are a lot of sites do not specify the picture,. Js/.css in the user's browser to cache one end of time, in these sites to switch multiple pages, will produce a lot of repetitive traffic.

We can reasonably assume that the picture of the site, the. js/.css file, will not change over a period of time. So we can configure Apache to modify the images of these sites, the. js/.css file cache time, and avoid duplicate transmission of the same file.

The configuration method is simple, in httpd.conf, open mod_headers, Mod_mem_cache, Mod_cache, Mod_file_cache, plus the following configuration:
Copy Code code as follows:

#local forward Proxy Server
Listen 5081

Include conf/extra/httpd-vhosts-5081.conf



Create a new text file, httpd-vhosts-5081.conf, in the conf/extra/directory (Windows version Apache). In this file, plus such a configuration (picture file cache 365 days, JS/CSS cache 1 hours):


Copy Code code as follows:

#local forward Proxy Server
Namevirtualhost *:5081

#local forward Proxy Server
<virtualhost *:5081>
Proxyrequests on
Proxyvia on
<locationmatch "\. (JS|CSS) $ ">
Header unset P3P
Header unset Cache-control
Header unset Expires
Header unset Pragma
Header unset ETag
Fileetag None

#cache 1 hour
Header set Cache-control "max-age=3600, public"
</LocationMatch>

<locationmatch "\. (gif|jpe?g|png) $ ">
Header unset P3P
Header unset Cache-control
Header unset Expires
Header unset Pragma
Header unset ETag
Fileetag None

#cache 365 days
Header set Cache-control "max-age=31536000, public"
</LocationMatch>

</VirtualHost>


Of course, you can also adjust the time parameter here, in seconds. You can use the excel/calculator to calculate the desired number of seconds in advance.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.