last-modified

Get file mtime with millisecond resolution from Java

我怕爱的太早我们不能终老 提交于 2019-11-30 08:57:44
问题 When I read the mtime of a file from Java using Files.getLastModifiedTime , the return value is truncated to whole seconds. I know this works on other systems to get mtimes with millisecond resolution, so what could be different about mine? Here is a complete standalone test which compiles and runs: import java.nio.file.attribute.FileTime; import java.nio.file.Files; import java.nio.file.Paths; public class Test { public static void main(String[] args) throws java.io.IOException { FileTime

How can I set the last modified time of a file from python?

南楼画角 提交于 2019-11-30 05:34:57
I have a python script that downloads a file over FTP using ftplib . My current download code looks just like the example in the ftp lib docs: ftp.retrbinary('RETR README', open('README', 'wb').write) Now I have a requirement that the file downloaded over FTP needs to have the same last modified time as the file on the FTP server itself. Assuming I could parse out the time from ftp.retrlines('list') , how can I set the modified time on the downloaded file? I'm on a unix based OS if that matters. Charlie Use os.utime : import os os.utime(path_to_file, (access_time, modification_time)) More

Finding file size and last modified of SFTP oldest file using Java

无人久伴 提交于 2019-11-29 15:38:24
I'm using JSch to get files from an SFTP server, but I'm trying to figure out a way to only get the oldest file, and to make sure that it is not currently being written to. The way I imagine myself doing this is first finding which file in the specified remote folder is oldest. I would then check the file size, wait x seconds (probably about 10, just to be safe) and then check it again. If the file size has not changed, I download the file and process it. However, I have no idea how to do this! If anybody knows how to do this, or knows of something else that supports SFTP that has this built

Get file mtime with millisecond resolution from Java

。_饼干妹妹 提交于 2019-11-29 09:45:38
When I read the mtime of a file from Java using Files.getLastModifiedTime , the return value is truncated to whole seconds. I know this works on other systems to get mtimes with millisecond resolution, so what could be different about mine? Here is a complete standalone test which compiles and runs: import java.nio.file.attribute.FileTime; import java.nio.file.Files; import java.nio.file.Paths; public class Test { public static void main(String[] args) throws java.io.IOException { FileTime timestamp = Files.getLastModifiedTime(Paths.get("/tmp/test")); System.out.println(timestamp.toMillis());

How can I set the last modified time of a file from python?

偶尔善良 提交于 2019-11-29 04:29:08
问题 I have a python script that downloads a file over FTP using ftplib. My current download code looks just like the example in the ftp lib docs: ftp.retrbinary('RETR README', open('README', 'wb').write) Now I have a requirement that the file downloaded over FTP needs to have the same last modified time as the file on the FTP server itself. Assuming I could parse out the time from ftp.retrlines('list') , how can I set the modified time on the downloaded file? I'm on a unix based OS if that

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

烈酒焚心 提交于 2019-11-29 01:15:58
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. Alnitak 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 @list = File::DirList::list('.', 'M'); Personally I wouldn't go with the ls -t method - that

缓存技术1

依然范特西╮ 提交于 2019-11-29 00:46:20
假设一个网站,需要提高性能,缓存可以放在浏览器,可以放在反向代理服务器,还可以放在应用程序进程内,同时可以放在分布式缓存系统中。 缓存策略图 从用户请求数据到数据返回,数据经过了浏览器,CDN,代理服务器,应用服务器,以及数据库各个环节。每个环节都可以运用缓存技术。 从浏览器/客户端开始请求数据,通过 HTTP 配合 CDN 获取数据的变更情况,到达代理服务器(Nginx)可以通过反向代理获取静态资源。 再往下来到应用服务器可以通过进程内(堆内)缓存,分布式缓存等递进的方式获取数据。如果以上所有缓存都没有命中数据,才会回源到数据库。 缓存的请求顺序是: 用户请求→HTTP 缓存→CDN 缓存→代理服务器缓存→进程内缓存→分布式缓存→数据库。 HTTP 缓存 当用户通过浏览器请求服务器的时候,会发起 HTTP 请求,如果对每次 HTTP 请求进行缓存,那么可以减少应用服务器的压力。 当第一次请求的时候,浏览器本地缓存库没有缓存数据,会从服务器取数据,并且放到浏览器的缓存库中,下次再进行请求的时候会根据缓存的策略来读取本地或者服务的信息。 HTTP 缓存流程图 一般信息的传递通过 HTTP 请求头 Header 来传递。目前比较常见的缓存方式有两种,分别是 强制缓存 对比缓存 强制缓存 当浏览器本地缓存库保存了缓存信息,在缓存数据未失效的情况下,可以直接使用缓存数据

浏览器缓存机制详解(一)

独自空忆成欢 提交于 2019-11-28 07:09:26
浏览器缓存机制可以极大的提升用户体验,另一方面会因为读取缓存而展示了错误的东西,因而在开发中要设法将其删除。 什么是浏览器缓存? 浏览器缓存就是把一个已经请求过的web资源(如html页面,图片,JS,数据)拷贝一份放在浏览器中。缓存会根据进来的请求保存输入内容的副本。当下一个请求到来的时候,如果是相同的URL,浏览器会根据缓存机制决定是直接使用副本响应访问请求还是向源服务器再次发起请求。 使用缓存的原因 (1)减少网络带宽消耗 当web缓存副本被使用时,只会产生极小的网络流量,可以有效降低运营成本。 (2)降低服务器压力 给网络资源设定有效期之后,用户可以重复使用本地缓存,减少对源服务器的请求,简介降低了对服务器的压力,同时搜索引擎的爬虫机器人也能根据过期机制降低爬取的频率,也能有效降低服务器压力。 (3)减少网络延迟 缓存的使用可以明显加快页面打开速度,达到更好的用户体验。 浏览器的缓存机制 对于浏览器的缓存来讲,这些规则是在HTTP协议头部和HTML页面的Meta标签中定义的。他们分别从新鲜度和校验值两个维度来规定浏览器是否可以直接使用缓存中的副本,还是需要去源服务器获取新版本。 过期机制:指的是缓存副本的有效期。一个缓存的副本必须满足以下条件,浏览器会认为它是有效的,足够新的: 1.含有完整的过期时间控制头信息(HTTP协议报头),并且仍在有效期内 2

HTTP缓存机制与原理详解

空扰寡人 提交于 2019-11-28 07:05:34
1.1 - 缓存 缓存可以重用已获取的资源能够有效的提升网站与应用的性能。 Web 缓存能够减少延迟与网络阻塞,进而减少显示某个资源所用的时间。 借助 HTTP 缓存,Web 站点变得更具有响应性。 缓存分为两点:强制缓存和协商缓存 1.2 - 强制缓存 概念 强制缓存就是向浏览器缓存查找该请求结果,并根据该结果的缓存规则来决定是否使用该缓存结果的过程。 简单来讲就是强制浏览器使用当前缓存 所请求的数据在缓存数据库中尚未过期时,不与服务器进行交互,直接使用缓存数据库中的数据。当缓存未过期时基本流程如下: 实现:通过服务器端设置响应头字段来控制强制缓存的过期时间 expires (http1.0) 其指定了一个日期/时间, 在这个日期/时间之后,HTTP响应被认为是过时的。但是它本身是一个HTTP1.0标准下的字段,所以如果请求中还有一个置了 “max-age” 或者 “s-max-age” 指令的Cache-Control响应头,那么 Expires 头就会被忽略。 cache-control (http1.1) 通用消息头用于在http 请求和响应中通过指定指令来实现缓存机制。 cache-control 优先级比 expires 高 expires 日期(new Date().toGMTString()) 缓存的最大有效时间 cache-control max-age(单位s)

C# - Download files from FTP which have higher last-modified date

為{幸葍}努か 提交于 2019-11-28 05:00:37
问题 I have an FTP server with some files. I have the same files in in a local directory (in C:\ ). When I'll run the program, I'd like it searches all files in the FTP server that have a last-modified timestamp later than the same file (equal name) in local directory and download all files founded. Can someone give me a help or a tip, please? I'll appreciate all answers! 回答1: Unfortunately, there's no really reliable and efficient way to retrieve timestamps using features offered by the .NET