No. 16 August growth topics

1.HTTP return difference codes 301 and 302?

301, 302 are encoded HTTP status, all represent a URL has shifted, except that: 
301 redirect: 301 represents the permanent transfer (Permanently Moved).
302 redirect: 302 representative of a temporary transfer (Temporarily Moved).

 

Each HTTP request and response are with corresponding header information. By default, while transmitting XHR request, following the header information is also sent:

Accept: Content browser can handle the type of
Accept-Charset: browser capable of displaying the character set
Accept-Encoding: compression-encoding the browser can handle
browser language currently set: the Accept-Language
Connection: the connection between the browser and the server type
Cookie: Cookie any of the current page settings
Host: requesting domain page where the
Referer: requesting the page the URL of
the user-agent: browser user agent string

About common http request header, and response header Detailed

A commonly used http request header

1.Accept

  • Accept: text / html browser can accept the type of server postback is text / html.
  • Accept: * / * represents the browser can handle all types (usually the browser to the server are made of this).

2.Accept-Encoding

  • Accept-Encoding: gzip, deflate encoding method affirm their own browser received, generally designated compression method supports compression, support what compression method (gzip, deflate), (Note: this is not the only character encoding).

3.Accept-Language

  • Accept-Language: zh-CN, zh; q = 0.9 browser affirm their own language received.

4.Connection

  • Connection: TCP keep-alive after a page opens when completed, for the transmission of HTTP data between the client and the server connection is not closed, if the client again visit this page on the server, will continue to use a connection has been established .
  •  Connection: TCP Representative close after completion of a Request for transmission of data between the HTTP server and the client connection will be closed, when the client sends a Request again, re-establishment of the TCP connection.

5.Host (transmission request, the header field is required)

  • Host: www.baidu.com request header field is mainly used to specify the Internet host and port number of the requested resource, it is usually extracted from the HTTP URL.

6.Referer

  • Referer: https: //www.baidu.com/ tn = 62095104_8_oem_dg when the browser sends a request to the web server, usually bring Referer, I tell the server which page links from over, whereby a server can get some? information for processing.

7.User-Agent

  • User-Agent: Mozilla / 5.0 (Windows NT 6.1; Win64; x64) AppleWebKit / 537.36 (KHTML, like Gecko) Chrome / 70.0.3538.110 Safari / 537.36 telling HTTP server, operating system and browser used by the client name and version .

8.Cache-Control

  • Cache-Control: private private by default response can only as a private cache, shared between users no longer
  • Cache-Control:public In response it will be cached and shared among multiple users. Normally, if desired HTTP authentication, automatically in response to private.
  • Cache-Control: must-revalidate response will be reused under certain conditions, to meet the next request, but it must go to the server to verify that it is not still up to date.
  • Cache-Control: no-cache response will not be cached, but the real-time resource request to the server.
  • Cache-Control: max-age = 10 the maximum set cache valid time, but this is the time parameter defines the size (for example: 60) instead of a defined point in time. The unit is [sec seconds].
  • Cache-Control:no-store Under any conditions, the response will not be cached, and will not be written to disk in the client, which is based on the use of certain sensitive response will be security considerations.

9.Cookie

Cookie is used to store information in order to allow some users to the server to identify the user's identity (most sites need to log in above would be more common), such as cookie will store some user name and password when the user logs will generate a client cookie to store information, such verification on the browser cookie information to the server by reading and adoption will determine that you are a legitimate user, allowing to view the page. Of course, not only the cookie data inside the range described above, there are a lot of information can be stored inside a cookie, such as sessionid like.

10.Range (for HTTP)

  • Range: bytes = specifies the first byte and the last byte positions 0-5. I used to tell the server what they want to take part of the object.

Second, the conventional http response header

1.Cache-Control (Cache-Control corresponding to the request)

  • Cache-Control: private private by default response can only as a private cache, shared between users no longer
  • Cache-Control: public  browser and cache servers can cache page information.
  • Cache-Control: must-revalidate every request for the client, the proxy server must find a cache server to verify whether obsolete.
  • Cache-Control: no-cache and browser cache server information should not be cached page.
  • Cache-Control: max-age = 10 is not bothering me in the notification browser 10 seconds, refresh yourself from the buffer.
  • Cache-Control: no-store  information requests and responses should not be stored in other disk systems.

2.Content-Type

  • Content-Type: text / html; charset = UTF-8 to tell the client, the type of resource files, as well as character encoding, utf-8 client by the resource is decoded, and then parse html resources. Usually we will see some sites are garbled, often the server does not return the correct code.

3.Content-Encoding

 

  • Content-Encoding: gzip tell the client, the server sends the resource is to use gzip encoding, the client see this information, resources should be used to decode gzip.

 

4.Date

  • Date: Tue, 03 Apr 2018 03:52:28 GMT This is the time when the server sends a server resources, GMT is the standard time Greenwich location. Time http protocol is sent GMT, which is mainly to resolve on the Internet, different time zones at each other when the requested resource, time confusion.

5.Server

 

  • Server: Tengine / 1.4.6 This is the server and the corresponding version, just tell the client server information.

 

6.Transfer-Encoding

 

  • Transfer-Encoding: chunked response header tells the client, the server sends the resource embodiment block is transmitted. Usually block transmission resources are dynamically generated by the server, the transmission do not know the size of the transmission resources, so the use of the transmission block, each block is independent, separate blocks can be designated their length, the last one is 0 length, when the client to read the block length of 0, may determine the transmission resources are already finished.

 

 

7.Expires

 

  • Expires: Sun, 1 Jan 2000 01:00:00 GMT The response header is associated with the cache, tell the client before this time, you can directly access the cached copy, it is clear that this value can be problematic, because the client and server time is not necessarily the same, if a different time can cause problems. So this is no response header Cache-Control: max-age = * the response header accurate because the max-age = date of the date is a relative time, not only better understood, and more precise.

8.Last-Modified

 

 

  • Last-Modified: Dec, last modification date of the object 26 Dec 2015 17:30:00 GMT requested (in "Hypertext Transfer Protocol Date" format as defined in RFC 7231 is represented)

 

9.Connection

  • Connection: keep-alive this field as a response to the client's Connection: keep-alive, tell the client tcp connection end server is also a long connection, the client can continue to use this tcp connection to send http request.

10.Etag

 

  • ETag: "737060cd8c284d8af7ad3082f209582d" is an object (such as URL) flag value, in relation to a target, such as a html file, if it is changed, it will not modify Etag, therefore, with the role of the role of the ETag Last-Modified almost, mainly for the WEB server to determine whether an object is changed. When such a request before a html file, get its ETag, when this time requesting the file, the browser will get the previous ETag value is sent to the WEB server, WEB server will then present the file with the ETag ETag comparison, then you know that the file has not changed.

11.Refresh

 

 

  • Refresh: 5; url = http: //baidu.com for redirecting, or when a new resource is created. Default refresh redirects after 5 seconds.

 

12.Access-Control-Allow-Origin 

  • Access-Control-Allow-Origin: * * Number behalf of all sites can cross-domain resource sharing, so if the current field to * Access-Control-Allow-Credentials can not be true
  • Access-Control-Allow-Origin: www.baidu.com specify which sites can share resources across domains

13.Access-Control-Allow-Methods

  • Access-Control-Allow-Methods: Which method GET, POST, PUT, DELETE allow access to the

14.Access-Control-Allow-Credentials

 

  • Access-Control-Allow-Credentials: true whether to allow sending cookie. By default, Cookie CORS not included in the request. Set to true, it means that the server explicit permission, Cookie can be included in the request sent to the server. This value can only be set to true, if the server is not sent by the browser Cookie, you can delete the field. If the access-control-allow-origin is *, the current field can not be true

 

15.Content-Range

  • Content-Range: bytes 0-5 / 7877 specifies the insertion position of a portion of the overall entity, he also indicates the length of the entire entity. Returns a response to the client part of the server, it must describe the response range covers the entire entity and the length

 

201-206 have said the request was successful
200- successful
201- has been created
202- Accepted: The server accepted the request, but did not deal with
203- unauthorized information
204- no content
205- Reset Content
206- part

300-307 indicates to fulfill the request, further action is required, the status code is typically redirected
400-417 indicates that the request may be wrong, the processing server impede
400- server does not understand the request syntax
401 authentication error
403 rejects the request server
404 web page (the most common server status) found
405 ways to disable
406- does not accept (the requested page can not use the content characteristic response to the request)
407- proxy authentication required
408 request timeout (server timed out waiting for the request)
409 conflict
410 - deleted
411- need effective length (server will not accept without a valid content-length header field of the request)
412- preconditions are not met
413- request entity too large
URL 414- request is too long
415 Unsupported media type
416 request range not meet the requirements of
417- to meet expectations

500-505, said: internal server error occurred while trying to process the request, the server is wrong, not the fault of the requested
500 internal server error
501 Server does not have the functionality to fulfill the request
502- error NM
503- server is not available (or overload down for maintenance, paused)
504- gateway timeout
505-http version is not supported (using the http protocol version requested server does not support)

Thread state?

Any thread generally has five states, namely creating, ready, running, blocking, termination

1, resulting in a method of blocking a thread?

Blocking thread method: join, yield, sleep and Object of wait () method

2, Java daemon (background process)?

Set the thread as a daemon: setDaemon (true) only if a process is running in a background thread, the process will end.

3, the resulting thread is blocked, which state the thread back?

By join, yield, after sleep causing blockage thread is returned to the ready state

3, after which the state is to return to the ready state?

 a) by join, yield, after sleep causing blockage thread is returned to the ready state

 b) after encountering synchronized

 c) after encountering wait wait Object methods

4, sleep will release the lock on it?

 sleep it will not release the lock will hold the lock [sleep]

5. What are the thread state? Specifically how to run?

There are threads: Create, ready, running, blocking, termination. 5 states

1. Create a new keyword by entering the nascent state

2. After calling start ready state

After 3.CPU schedule to this thread, the thread begins execution. Into running state

4. Run encountered join, yield, sleep causing blockage, enter the blocked state. After the completion of occlusion, back to the ready state

5. Thread the normal completion of the implementation, or experience an abnormal termination, enter the state of death

6, terminate the thread, which has several methods?

 Thread calls stop () method, destory () method or after the end of the run () method execution, the thread that is in the state of death. Thread is in state of death does not have the ability to continue to run.

 

 

How to ensure the security thread

 

 

InnoDB and MyISAM
Mysql default MyISAM storage engine prior to 5.5, after use InnoDB.
MyISAM tables use operational data is locked, you update a record will lock the entire table, resulting in lower performance, concurrency is not high. Of course, it also does not exist deadlock.
The biggest difference InnoDB and MyISAM are two points: First ** InnoDB support transactions; the second is InnoDB uses row-level locking **.
In Mysql, the row-level locking is not directly record lock, but lock index. Index divided into the main key index and non-primary key index are two, if a sql statement the operation of the primary key index, Mysql will lock this primary key index; if a statement the operation of the non-primary key index, MySQL will first lock the non-primary key index, then locked related to the primary key index. If you do not retrieve data through index conditions, then the InnoDB table will lock all the data, the actual results with the same table lock.

Optimistic and pessimistic locking lock
optimistic lock: no concurrency issues always think, every time to get the data and believe that there will be no other threads to modify the data, it will not lock, but in the other thread update will judge before that there is no data can be modified, usually a version number or CAS operating mechanism to achieve.
version: Normal plus a data version number is the version field in the data table represents the number of data is modified, and when data is modified, plus a version value. When a thread A to update the data values will be read version value while reading data, when submitting the update, if just to read the version when the update is version equal value in the current database, or retry update until the update is successful.
Core SQL code:
Update Table X = X + SET. 1, Version Version +. 1 WHERE ID = = # {ID} and {Version} Version # =;
CAS operation: i.e., compare and swap, or compare and set, involving three operand memory where the value of the data, the expected value, new value. When needs to be updated, it is determined to take a value before the current value of the memory are equal, if equal, updated with the new value, if the retry fails, a general spin operation, i.e. continuously retries.
Optimistic locking Optimistic locking only in general high concurrency, reading and writing less scene.

Pessimistic locks: always assume the worst case, every other thread modifies think when fetching data, it will lock (read lock, write lock, line lock, etc.), when other threads that want to access the data, you need to blocked pending. Can rely on database implementation, such as row locks, read and write locks, are locked before the operation. Shared lock, exclusive lock is pessimistic locking.
But when the amount of concurrency is very large, because the lock consumes resources and time may be locked once pessimistic locks a resource, other resources required to operate the consumer, can only wait until the lock is released, the benefits that can reduce concurrency, by too long, easily lead to system performance degradation, resource depletion serious. So in general we can not very big in the amount of concurrency, and when an abnormality occurs concurrent users and the system has led to very difficult to accept, will choose to be pessimistic locking.

Shared locks and exclusive locks
CRUD operations on the database default will add exclusive lock, and the query does not add any locks.
Shared lock (read lock): shared locks for a resource, the resource itself can be read, others can read the resource (also shared locks can continue that shared locks can coexist more), but can not be modified. To modify it must wait after all shared locks are completely released. The syntax is:
the SELECT * from the Table Lock in the MODE report this content share
exclusive lock (write lock): for a resource plus exclusive lock itself can be CRUD, other people can not do anything. The syntax is:
the SELECT * from the Table for Update - additions and deletions to automatically add the exclusive lock

 

MySQL type index
  1. General index  which is the most basic index , it does not have any restrictions, such as the above title field created for the index is a general index , MyIASM BTREE the default type of index , also we use in most cases the index . ...
  2. The only index  ...
  3. Full-text index (FULLTEXT) ...
  4. A separate index , multi-column index  ...
  5. Combination index (leftmost prefix)

 

Guess you like

Origin www.cnblogs.com/whymoney1000/p/11366637.html