Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-06-02 01:03:16
Point:500 Replies:4 POST_ID:828558USER_ID:11059
Topic:
Apache Web Server;;PHP Scripting Language
Normally we can check the HTTP connection status by $info = curl_getinfo($curl) and
echo out $info['http_code'] in php , for example HTTP 200 OK for request success which
is generated from the server for client request.
But for HTTP 304 status code for curl php program, a little bit confused for me, Just want to know the mechanizm of http 304(not modified) generation. Is the http 304 generated by Broswer like Firefox when curl_exec() is sumbitted if previous same webpage is
requested again ? If so, browser
will check the cache folder and check whether the request webpage is existing on client/user computer. If existing, it won't process curl_exec function and just cache the webpage from users' computer to users and header out http 304 code. IF not exising, browser will let the curl_exec() in php program to continue.
Is that what I said is correct ?
When I output the http_code from getinfo($curl), it will report HTTP 304 when
the firefox cache setting on tool menu and uncheck the stopping cache box and request the same webpage again. When I disable stopping cache box on Firefox, it means no caching file, HTTP 304 code won't be generated, the http code is always HTTP200 OK
or HTTP 301 Moved permentantly
Qusetion-1 http 304(not modified) status code is generated by broswers instead of server. ?
Question-2 server can be able to check client's cache setting or ability and header("HTTP1.1 304 Not Modified) in php and echo to header of the webpage if
users requested the webpage is owned by server , Right ?
Please advise
Duncan
echo out $info['http_code'] in php , for example HTTP 200 OK for request success which
is generated from the server for client request.
But for HTTP 304 status code for curl php program, a little bit confused for me, Just want to know the mechanizm of http 304(not modified) generation. Is the http 304 generated by Broswer like Firefox when curl_exec() is sumbitted if previous same webpage is
requested again ? If so, browser
will check the cache folder and check whether the request webpage is existing on client/user computer. If existing, it won't process curl_exec function and just cache the webpage from users' computer to users and header out http 304 code. IF not exising, browser will let the curl_exec() in php program to continue.
Is that what I said is correct ?
When I output the http_code from getinfo($curl), it will report HTTP 304 when
the firefox cache setting on tool menu and uncheck the stopping cache box and request the same webpage again. When I disable stopping cache box on Firefox, it means no caching file, HTTP 304 code won't be generated, the http code is always HTTP200 OK
or HTTP 301 Moved permentantly
Qusetion-1 http 304(not modified) status code is generated by broswers instead of server. ?
Question-2 server can be able to check client's cache setting or ability and header("HTTP1.1 304 Not Modified) in php and echo to header of the webpage if
users requested the webpage is owned by server , Right ?
Please advise
Duncan
Author: duncanb7 replied at 2024-06-04 10:42:56
Dear All,
I am sorry that I am using proxy server to do my php coding, the
HTTP 304 is sent from the proxy server in which it will check
the request is in users browser cache or not , if yes, it will use
cache for request, That is why my curl code will receive
HTTP 304 and no any return html code.
Yes only server will sent the HTTP 304 code to the
requestor by intention only and normally users will
receive 200 OK or 302 permentanly moved for the most
THanks
Duncan
I am sorry that I am using proxy server to do my php coding, the
HTTP 304 is sent from the proxy server in which it will check
the request is in users browser cache or not , if yes, it will use
cache for request, That is why my curl code will receive
HTTP 304 and no any return html code.
Yes only server will sent the HTTP 304 code to the
requestor by intention only and normally users will
receive 200 OK or 302 permentanly moved for the most
THanks
Duncan
Accepted Solution
Expert: Ray Paseur replied at 2024-06-02 17:22:26
167 points GOOD
Browsers do not change the communication for server CURL functions, ...
Browsers do not use CURL functions. Automated scripts running on other servers use CURL functions in order to appear to be browsers. If the automated script acts like a well-behaved client browser, accepting and returning cookies and following redirection instructions, the server will not be able to tell whether the client making the requests is a web browser operated by a human being or a server running CURL functions. Assisted Solution
Expert: Slick812 replied at 2024-06-02 12:30:48
167 points GOOD
greetings duncanb7, , the web server response of 304 is not usually sent for an HTTP standard request for a file, the 304 IS SENT for "information" requests from a browser, or as you use another server request.
Browsers do not change the communication for server CURL functions, as far as I know.
You say that you use - curl_getinfo( ) , which is probally the reason for the 304 response, however, as far as I can remember, there should be a request header set to tell the responder what "Date" the information of the file is needed, and if it is the same date, you get the 304 back. You might look more closely at your setup for using curl_getinfo( ) ;
Browsers do not change the communication for server CURL functions, as far as I know.
You say that you use - curl_getinfo( ) , which is probally the reason for the 304 response, however, as far as I can remember, there should be a request header set to tell the responder what "Date" the information of the file is needed, and if it is the same date, you get the 304 back. You might look more closely at your setup for using curl_getinfo( ) ;
Assisted Solution
Expert: Ray Paseur replied at 2024-06-02 06:14:55
166 points GOOD
See 10.3.5 304 Not Modified on this page.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
The HTTP response codes are generated by the server. The server cannot check the client cache. It is the server's responsibility to know what was sent in response to the last identical GET request from a given client, and the server may choose to send the header 304 instead of a message body. In practice I find this to be rare; the server usually sends the message body.
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
The HTTP response codes are generated by the server. The server cannot check the client cache. It is the server's responsibility to know what was sent in response to the last identical GET request from a given client, and the server may choose to send the header 304 instead of a message body. In practice I find this to be rare; the server usually sends the message body.