last-modified

how to tell when a HTTP web page has changed when it is of type html/text?

狂风中的少年 提交于 2020-01-14 06:10:06
问题 I'm trying to work out the algorithm to tell if non-binary files on the web have changed or not. I was going to go with: LastModified datetime from header, and then if these aren't present fallback to ContentLength from header I'm finding however that for alot of websites the LastModified for the HTML pages are actually just using the current DateTime, hence the approach doesn't work (i.e. would lead to an indication that the page is always changing) I think...? What would be a good algorithm

How to preserve date modified when retrieving file using Apache FTPClient?

蓝咒 提交于 2020-01-11 05:59:28
问题 I am using org.apache.commons.net.ftp.FTPClient for retrieving files from a ftp server. It is crucial that I preserve the last modified timestamp on the file when its saved on my machine. Do anyone have a suggestion for how to solve this? 回答1: This is how I solved it: public boolean retrieveFile(String path, String filename, long lastModified) throws IOException { File localFile = new File(path + "/" + filename); OutputStream outputStream = new FileOutputStream(localFile); boolean success =

Why does django-lint tell me the `auto_now_add` is deprecated?

僤鯓⒐⒋嵵緔 提交于 2020-01-10 19:35:10
问题 Hi fellow Djangonauts: I checked my project with django-lint, and it yields: W:211,16:MyModel: timestamp: Uses superceded auto_now or auto_now_add The commit message: auto_now/auto_now_add not technically deprecated, but they still suck. Why do they say auto_now/auto_now_add "suck"? I had no problem implementing the created/last-updated pattern with these two field parameters. Is there a better approach for this pattern? Custom Field classes? And why (if this approach is better) it hasn't

Get last modified time of file in linux

China☆狼群 提交于 2020-01-09 10:02:08
问题 I am working on a C program where I need to get the last modified time of the file. What the program does is a function loops through each file within a directory and when a particular file(s) is found it calls another function to check that the last modified times of the file. Within the directory there is a mylog.txt.1 , mylog.txt.2 and mylog.txt.3 etc. When I list the directory in linux using the ll command I can see that mylog.txt.1 and mylog.txt.2 were modified on the 4th May and mylog

How to generate 'last-modified' http header for a resource?

懵懂的女人 提交于 2020-01-06 06:08:58
问题 I currently read this about ' last-modified ' HTTP header. Though I have read number of sources, I'm still confused how it is generated for a particular resource. Is it solely depends on the time stamp when the resource has changed in the db. i.e. as PUT requests are processed for the db. on the same resource? Or are there any generalized or nearly generalized logic to tackle the problem? And the generation of last-modified time, is it solely a responsibility of the actual application? or are

Java: Detecting modification to a file (file polling?)

爱⌒轻易说出口 提交于 2020-01-01 14:39:34
问题 What is the most efficient way to detect modification to a file in Java? I've read about file polling however, the polling approach has a number of drawbacks that become apparent as the number of watched files increases. I rather not use polling but a number of solutions online appear to point to file polling as the recommended method. I was hoping for perhaps an OS-related file system update callback solution instead -- is this possible in both linux and windows? Given that I currently only

前端HTTP 缓存简单了解

China☆狼群 提交于 2019-12-31 12:58:51
始发掘金: 《前端HTTP 缓存简单了解》 同步到博客园。 HTTP 缓存简单了解。文章整理了相关资料,记录了部分实践。方便大家轻松了解缓存。能回答上三个问题,HTTP缓存就算理解呢。能否缓存?缓存是否过期?协商缓存? 概要: web缓存 缓存的处理 前端解决方案 总结 1. web缓存 Web缓存是可以自动保存常见文档副本的 HTTP 设备。当 Web请求抵达缓存时, 如果本地有“已缓存的”副本,就可以从本地存储设备而不是原始服务器中提取这个文档。《HTTP权威指南》 缓存是一种存储给定资源副本并在请求时将其提供回来的技术。 当Web缓存在其存储中具有请求的资源且能用时,它将拦截该请求并返回其副本,而不是从原始服务器重新下载。 关键字:缓存,原始服务器(产生原始文档) 1.1 缓存类型 缓存的种类:浏览器缓存(本文讨论点),代理缓存,网关缓存。 以上种类 缓存工作的原理 是一致的,只是缓存所在的位置不同,涉及面更宽广。 这几种缓存,可以分为两大类: 专用缓存(私有缓存):私有缓存专用于单个用户。 共享缓存:多用户共享。 图片源:HTTP caching 上图展示了: 没有缓存: 没有缓存直接向服务器请求资源。 共享缓存: 当用户Browser1请求资源,经过缓存服务器,缓存服务器也没有资源,向原始服务器请求资源。得到资源后,缓存服务器缓存资源并返还数据给Browser1

How can I find the newest created file in a directory?

旧巷老猫 提交于 2019-12-29 05:04:45
问题 Is there an elegant way in Perl to find the newest file in a directory (newest by modification date)? What I have so far is searching for the files I need, and for each one get it's modification time, push into an array containing the filename, modification time, then sort it. There must be a better way. 回答1: Your way is the "right" way if you need a sorted list (and not just the first, see Brian's answer for that). If you don't fancy writing that code yourself, use this use File::DirList; my

What takes precedence: the ETag or Last-Modified HTTP header?

為{幸葍}努か 提交于 2019-12-28 07:58:11
问题 For two subsequent requests, which of the following two headers is given more weight by browsers should one of them change: ETag or Last-Modified? 回答1: According to RFC 2616 section 13.3.4, an HTTP 1.1 Client MUST use the ETag in any cache-conditional requests, and if both an ETag and Last Modified are present, it SHOULD use both. The ETag header is considered a strong validator (see section 13.3.3), unless explicitly declared weak by the server, whereas the Last Modified header is considered

PHP - Download file and preserve timestamp?

帅比萌擦擦* 提交于 2019-12-24 01:19:48
问题 As the name suggests, is there a quick way to download a file, but bring the timestamp along? I'm writing a basic cache that, among other checks, determines (via get_headers ) if a given local file is the same as it's remote counterpart. I know I can file_get_contents / file_put_contents and then touch() the file with the results of get_headers , but the calling that is making another HTTP call (even if it is a HEAD call) and I'd only like to test Last-Modified as a last resort. So is there a