First, The Concept And Working Principle Of Proxy Server


Proxy server (A) the concept of proxy server with the rapid development of Internet technology, more and more computers connected to the Internet. Many companies also have their own corporate LAN access to the Internet. How to quickly access Internet sites, improve network security, has become a hot topic today. In this case, the proxysite came into being.

Concept Of Proxy Server

The concept of proxy server, it is an intermediary between the personal network and Internet service agencies, which is responsible for forwarding legitimate network information, the forwarding control and registration. As a bridge between Internet and Internet, proxy server plays an extremely important role in practical application.

It can be used for many purposes, the most basic function is to connect, in addition to security, cache, content Filtering, access control management and other functions. Proxy server, as its name suggests, is a machine that cannot directly access the Internet in the local area. It sends the Internet access request (for example, browsing a certain home page) to a proxy server that can directly access the Internet.

Then the proxy server completes the Internet access request, into the proxy server’s cache; then pass this page to the requester. Such machines on the LAN are just as capable of accessing the network directly. And, the proxy server can also be some of the site’s filtering and control functions, thus enabling us to control and save Internet costs.

Proxy servers allow computers without IP addresses to use their proxy features to quickly and securely access Internet resources. When the proxy server client sends an external resource access request, the request is first recognized by the proxy server and requested by the proxy server to request resources.

Because the general proxy server has a large bandwidth, high performance, and can intelligently cache browsed or unbrowsed website content, under certain circumstances, the client can access the network resources through the proxy server more quickly. Common examples of proxy server applications: A LAN with hundreds of computers can also access the external Internet through a proxy server that has access to external network resources.

The function of the proxy server

The LAN port, Serving as a connection between the LAN and the external network serves as a connection port between the LAN and the external network. At the same time, the internal network structure is shielded from the external network so that the external network cannot directly access the internal network. At this point, the proxy server acts as a gateway.

What Is Proxy mode?

proxy site

Proxy mode use the proxy object to complete the user request, shielding the user’s access to the real object. Real-world agents are empowered to carry out some matters of the parties without the need for the parties to come forward. From a third-party perspective, it seems that the parties do not exist because they only communicate with the agents. In fact, agents must have the authority of the parties, and on the core issues also need to ask the parties.

There are also a number of intent to use the proxy mode in software design, such as the need to shield the client from direct access to real objects for security reasons, or the technical details (such as RMI) of using proxy classes to handle remote method calls in remote calls Improve system performance, and encapsulate real objects so as to achieve the purpose of lazy loading.

Agent mode role is divided into four kinds:

Thematic Interfaces: A public external method that defines proxy classes and real topics, and is also a way to represent the true topic of proxy classes;

The real theme: the real business logic class;

Agent category: used to proxy and package the real theme;

Main: Client, using proxy classes and thematic interface to do some work.

Lazy loading

A simple example to explain the use of proxy mode lazy loading method and its significance. Suppose a client software based on user requests to the database query data. Before querying data, you need to get the database connection, initialize all the classes of the system when the software is turned on, and try to get the database connection.

When the system has a large number of similar operations exist (such as XML parsing, etc.), all of these initialization operations will make the system start very slow. To this end, the use of the proxy mode proxy encapsulation of the database query initialization operation, when the system starts, initialize this proxy class, rather than the real database query class, and the proxy class did not do anything. Therefore, its construction is quite rapid.

When the system is started, the method that consumes the most resources is separated by the proxy mode, which can speed up the startup of the system and reduce the waiting time of the user. In the real user query operation by the proxy class alone to load the real database query class to complete the user’s request. This process is to use the proxy mode to achieve a lazy loading.

Core idea behind deferred loading Proxysite

The core idea behind deferred loading is that if you do not currently use this component, you do not need to actually initialize it, use a surrogate object instead of its original location, and load it whenever you really need it. It is very meaningful to use the lazy loading of the proxy mode.

Firstly, it can distribute the system pressure on the timeline. In particular, it does not have to complete all the initialization tasks at the system startup, so as to speed up the startup time. Secondly, for many real themes, May not be called at all until the software is started until it is shut down. Initializing these data is a waste of resources.

For example, using the proxy class encapsulates the database query class, the system startup process for this example. If the system does not use the proxy mode, it is necessary to initialize the DB Query object at startup, and use the proxy mode, only need to initialize a lightweight object DB Query Proxy at startup.

The following code ID Query is the thematic interface, defines the proxy class and the real class needs external services, defines the common method request () function to achieve database queries. DB Query is the real theme, responsible for the actual business operations, DB Query proxy class.