A simple, HTTP proxy with caching

Source: Internet
Author: User

The 1.0 model is very easy right now. That is, the request from the client is simply processed and forwarded to the server. Check the local cache before forwarding. Suppose there is. Directly to the customer's local resources

The program flow is generally for example with:



Caching is done by saving the file to disk and then recording the index in memory, such as the following, perhaps considering adding other fields. such as timestamps.

typedef struct CACHE_NODE {char Name[max_line_size];char path[max_line_size];struct cache_node * NEXT;} cache_node;typedef struct Cache {int init_size;int current_size; Cache_node fileset[max_cache_size];} Cache;


and the forwarding section. is by parsing and re-filling the URL field in the request header, and then forwarding the requested implementation.

At this stage only the GET request can be processed.


The following are simple to use:

First configure the browser, take Firefox as an example (this program executes in the local 11111port)

watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvc2ltb25feglhx3vlc3rj/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma== /dissolve/70/gravity/southeast ">


Login directly to access the Welcome screen:




Test, with Sogou homepage for example:




It was a rather hasty act. Just to achieve the main function, there is a lot to improve the place, first mark here.


The problems that now exist:

1, the Web page is large or the element type is too long. There are certain bugs

2, some cache file storage has an exception.


Perhaps the version number to improve the place:

1, the cache file storage form and search efficiency and so on to improve. Even the form of a cache.

2, to improve the efficiency of the agent, for example, each time the request to find the IP is a very time-consuming process.


The specific code of the program is: Https://github.com/simon-xia/mini_proxy

What suggestions do you have for passing friends?

A simple, HTTP proxy with caching

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.