- 浏览: 278649 次
- 性别:
- 来自: 大连
-
文章分类
最新评论
-
fei33423:
其实查看源代码你可以发现 update其实是调用了execut ...
JdbcTemplate 中execute和update的区别: -
CoderDream:
不错,感谢分享!
为绿色版NOTEPAD++添加右键菜单 -
t382159355:
谢谢分享..感激不尽.
java中this用法 -
風一樣的男子:
kankan1218 写道風一樣的男子 写道出乎意料??
菜B ...
结果出乎大部分人的意料 -
feipigzi:
引用java教程中的一段话:我们可以这样理解子类创建的对象:1 ...
结果出乎大部分人的意料
更具if modified since更新图片,并且删除陈旧的图片:
# --------------------------------------------- # This method will get the document identified by $url and store it in file called $filename. # If the file already exists, then the request will contain an "If-Modified-Since" header matching the modification time of the file. # If the document on the server has not changed since this time, then nothing happens. # If the document has been updated, it will be downloaded again. # The modification time of the file will be forced to match that of the server. # The return value is the the response object. # Modify Log # 11/29/2010 edison create # --------------------------------------------- sub mirrorFile { my($this, $url, $file) = @_; my $browser = $this->{'browser'}; my $request = HTTP::Request->new('GET', $url); # If the file exists, add a cache-related header if ( -e $file ) {print "exist\n"; my ($mtime) = ( stat($file) )[9]; if ($mtime) { $request->header( 'If-Modified-Since' => HTTP::Date::time2str($mtime) ); } # use the current time to replace the last access time my $last_access_time = time(); utime $last_access_time, $mtime, $file; } my $tmpfile = "$file-$$"; # If a $tmpfile is provided with the :content_file option, then the response content will be saved here instead of in the response object. my $response = $browser->request($request, $tmpfile); if ( $response->header('X-Died') ) { die $response->header('X-Died'); } # Only fetching a fresh copy of the would be considered success. # If the file was not modified, "304" would returned, which # is considered by HTTP::Status to be a "redirect", /not/ "success" if ( $response->is_success ) {print "success\n"; my @stat = stat($tmpfile) or die "Could not stat tmpfile '$tmpfile': $!"; my $file_length = $stat[7]; my ($content_length) = $response->header('Content-length'); if ( defined $content_length and $file_length < $content_length ) { unlink($tmpfile); die "Transfer truncated: " . "only $file_length out of $content_length bytes received\n"; } elsif ( defined $content_length and $file_length > $content_length ) { unlink($tmpfile); die "Content-length mismatch: " . "expected $content_length bytes, got $file_length\n"; } # The file was the expected length. else { # Replace the stale file with a fresh copy if ( -e $file ) { # Some dosish systems fail to rename if the target exists chmod 0777, $file; unlink $file; } rename( $tmpfile, $file ) or die "Cannot rename '$tmpfile' to '$file': $!\n"; # make sure the file has the same last modification time # and use the current time to replace the last access time if ( my $lm = $response->last_modified ) { my $last_access_time = time(); utime $last_access_time, $lm, $file; } } } # The local copy is fresh enough, so just delete the temp file else { unlink($tmpfile);print "unsuccess\n"; } return $response; }
# --------------------------------------------- # Remove images which are not fresh enough to save disk space. # Modify Log # 11/30/2010 edison create # --------------------------------------------- sub removeStaleImages { my $this = shift; my $settedNotAccessDay = $this->{'config'}->{'image_not_access_day'}; if(!$settedNotAccessDay){ die "miss 'image_not_access_day' in base.conf file\n"; } if($settedNotAccessDay =~ /[^\d]/){ die "'image_not_access_day' in base.conf file should be numeric\n"; } my $deleteImageCount = 0; my $data_feed_path = $this->{'config'}->{'data_feed_path'}; my @fullPathImages = glob($data_feed_path.'/??/??/*'); foreach (@fullPathImages){ my @stat = stat($_) or die "Could not stat imagefile '$_': $!"; my $atime = $stat[8]; my $timeNotAccess = time()-$atime; if($timeNotAccess > $settedNotAccessDay*24*3600){ unlink $_; $deleteImageCount ++; } } Log::Write::setLog('A400004',{'COUNT'=>$deleteImageCount}); }
发表评论
-
Perl单元测试
2011-02-15 14:47 18591 测试内容和常用模块 ... -
Xpath基本用法
2011-01-04 17:13 1620my $liStr = $tree->findnode ... -
perl ssh scp 操作远程机器进行验证
2010-12-24 18:13 1837#!/usr/bin/perl use strict; ... -
保存cookie到本地,发送请求时带着cookie。
2010-12-10 17:44 1754use Data::Dumper; use LWP:: ... -
How to deal with 'https'
2010-12-08 15:00 986Windows http://johnbokma.com/pe ... -
Mechanize 模块 可以提交form,实现登录功能
2010-10-26 10:36 1438Mechanize 模块 可以提交form,实现登录功能 : ... -
perl模块推介
2010-10-26 10:07 3159模块推介 取自 PerlChina.org - wiki ... -
WWW::Mechanize使用手册
2010-10-26 09:57 1945Mechanize使用手册(翻译 ... -
用LWP简单编写WEB访问的应用 ----需要登陆的网站,保留服务器返回的cookie
2010-10-25 12:38 2684LWP 是 Library for WWW access ... -
perl高级排序
2010-10-08 14:55 6561高级排序 ... -
【精】LWP与WEB的基本使用
2010-09-25 16:44 2007LWP 与 WEB 的基本使用: http://wiki. ... -
优化 Perl , 榨取代码的最大性能
2010-09-25 11:11 1450转载自:http://www.ibm.com/develope ... -
perl 模拟post提交
2010-08-26 18:05 1595对于post分页的网站,用正常的在url后面加参数的方法已经不 ... -
Perl 的 utf8 与编码处理
2010-08-19 12:48 2977本文基于笔者查阅的 perldoc 和试验结果。鉴于经常有人 ... -
Perl Unicode全攻略
2010-08-19 12:47 1246耐心看完本文,相信你今后在unicode处理上不会再有什么问题 ... -
perl 读写文件
2010-08-15 23:52 5911用Open() 函数打开文件 打开文件的常用方法是: op ... -
perl数据结构
2010-08-15 23:12 9941,{}:hash的引用, $product = {'Reta ... -
perl开发环境可以单步调试:eclispe+epic+PadWalker模块
2010-08-15 19:24 2136eclispe+epic+PadWalker模块: 1。假设已 ... -
perl特殊符号
2010-08-13 13:59 11981.$!记录打开文件句柄时的出错信息 2.$@记录eval捕获 ... -
perl的pop跟push操作数组的最右边,shift跟unshift操作数组的最左边
2010-08-13 10:25 3321perl的pop跟push操作数组的最右边,shift跟uns ...
相关推荐
在后续请求中,客户端会在HttpRequest Header中发送If-Modified-Since报头,包含之前接收到的Last-Modified时间。如果服务器上的文件自上次请求后未被修改,服务器将返回304 Not Modified状态码,客户端则直接从本地...
- 关闭ETags机制,使用Last-Modified和If-Modified-Since头代替,简化缓存验证流程。 12. **Ajax缓存技术** - 实现智能Ajax缓存策略,减少服务器端的数据请求。 13. **最小化技术** - 对图片等资源进行适当的...
- Last-Modified和If-Modified-Since:通过资源的最后修改时间进行验证。 6. 安全与隐私: - HTTPS:HTTP加上SSL/TLS加密,确保通信安全。 - CORS:跨源资源共享,允许不同源之间的交互。 - Content-Security-...
11. **Ajax 缓存问题**:发送 AJAX 请求时,可以通过设置请求头 "If-Modified-Since" 为 "0" 来避免浏览器使用缓存的响应,确保每次请求都从服务器获取最新数据。 以上是对前端面试中常见 JavaScript 知识点的详细...
常见的缓存控制头有Cache-Control、ETag、If-None-Match、If-Modified-Since等。 六、HTTP安全 HTTPS(HTTP over SSL/TLS)是HTTP的安全版,通过SSL/TLS协议为HTTP提供了加密处理、服务器身份验证和消息完整性检查...
它支持多种缓存验证头,如`If-Modified-Since`和`ETag`,使得服务器能够指示客户端何时应当从缓存中读取数据,而不是每次都从服务器获取新数据。 #### 三、HTTP/1.1协议关键概念 ##### 3.1 请求(Request) 客户端向...