| |

VerySource

 Forgot password?
 Register
Search
Author: flair_yjl

How to get the last update time of the webpage? ? ? ?

[Copy link]

0

Threads

39

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-7-29 00:45:01
| Show all posts
System.out.println(new Date(con.getDate()));
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-7-29 11:00:01
| Show all posts
In the agreement, Last-modified is indeed SHOULD level
HTTP/1.1 servers SHOULD send Last-Modified whenever feasible.

Date should be obtained forever, because according to the agreement

Origin servers MUST include a Date header field in all responses, unless
1 When the status code 100 (continue) or 101 (switch protocol) is returned, MAY include a Date header field
2 When the server processes the request response, an error occurs, such as when the status code 500 (internal error) or 503 (service unavailable) is returned
3 The server does not have a reliable clock (???)

However, this and Last-modified required by the original poster belong to two concepts.
Date is actually when the response was output, and Last-modified has more meaning. For static files, it refers to the last update time of the files saved by the system
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-7-29 11:45:01
| Show all posts
It seems that there is no particularly good solution, the host can decide the last update time according to the priority below

1 Last-modified
2 Date
3 Client system time
Reply

Use magic Report

0

Threads

4

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-29 20:30:02
| Show all posts
Finally add the following Script in the net surface:
...
<script type="javascript/text">
<!-- hide script from old browsers
    document.write("Last Modified:" + document.lastModified)
    // end hiding contents
-->
</script>
</BODY></HTML>
Reply

Use magic Report

0

Threads

63

Posts

42.00

Credits

Newbie

Rank: 1

Credits
42.00

 China

Post time: 2020-7-30 12:00:02
| Show all posts
js document.lastModified can only get the time of this page/or other pages of this site, it can't do anything about cross-domain, and lz seems to need to run on the server side
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list