手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 免费部署 N8N 的 Zeabur 注册 | 登陆
浏览模式: 标准 | 列表2025年12月的文章

CDN缓存策略FAQ

CDN这个东西,当然是个好东西。。。所以看到有FAQ就理所当然的复制下来,其实,最近我突然想到一件事情,中国的地区域名还有一个很有意思的地域域名,那就是js.cn,所以,我悄悄的申请了两个域名,cache.js.cn和cdn.js.cn,就是想用来做这种CDN转发,当然,只是简单的。。。

我最初的想法是(有一小部分),如果我的服务器里有N多人装了DZ论坛,那么这些JS和CSS其实都是共用的。如果我都用同样的域名进行转发,那,其实节约了很多空间,也节约了带宽。因为同一个域名出来的JS和CSS文件,理论上是应该被缓存的哦。。

以下内容就是FAQ,自己也学习一下。。。

1.CDN加速原理
通过动态域名解析,网友的请求被分配到离自己最快的服务器。CDN服务器直接返回缓存文件或通过专线代理原站的内容。
网络加速+内容缓存,有效提供访问速度

2.CDN节点数量
全国多个机房,每个机房多台服务器,CDN节点一般上百台

3.CDN缓存什么内容
缓存html、图片、css、xml等静态资源,不缓存含有?的动态地址、jsp、php,js文件也不缓存【除非特殊设置】
缓存原站返回HTTP状态为20*或304,不缓存其他状态(例如404,500,503)

4.CDN缓存内容的更新
a)用户首次请求,CDN从原站抓取后缓存,直到文件过期后有用户请求再次更新
b)程序主动通知CDN抓取

5.CDN缓存内容的有效期
a)原站apache吐出的静态文件:由apache的expire和header模块控制
主要两项:last-modified,cache-control:max-age
apache缺省配置,所有静态文件在cdn只缓存3600s【需要我们按需求调整被加速服务器的apache设置】
3600s后cdn失效,用户访问时会重新请求原站,如果没有变化,缓存失效周期自动延长10%。
b)原站jsp或php吐出的动态内容(url形式必须是静态的)
由程序控制last-modified,cache-control:max-age public ,apache的设置将不起作用
cdn根据这两项判断是否需要到原站更新内容

6.CDN和应用的结合策略
a)变化不频繁的页面:例如图吧的图片显示页、车型页、已结束的比赛对阵页
在原站生成静态页面,原站apache上定义过期时间,例如1天。
原站上静态文件更新后,可以等待cdn过期。或者主动通知cdn更新(随着cdn节点越来越多,代价会非常高)
b)变化频繁的页面:例如足球库中的及时亚盘、及时欧赔、正在进行的比赛对阵页
不生成静态页面,由jsp或php定义过期时间,例如5s或60s。cdn过期后,如果有用户访问就从原站上抓取。
优点:相关页面内容更新后,不需要主动通知100个原站都来抓取,有效降低原站的压力。
如果页面内容没有变化,返回lastmodified不变,这样原站会直接返回304给cdn,cdn也会返回304给用户。减少网络传输和速度
比赛结束后,“正在进行的比赛对阵页”转换为第一类情况,再生成静态文件
c)特殊静态资源:例如图片库和某些大型产品库中的评论js
或者频繁访问、频繁更新的页面:例如足球赛事库的及时比分文件
通过apache nocache告诉IE不缓存,html中就不需要使用pinglun.js?123456这样的代码形式
然后用max-age告诉cdn缓存1s,这样避免每次用户请求都转到原站

本文来源:http://71j.cn/archives/10

Tags: cdn

Content-Type大全

原文的来源是一国外网站,而我当然就不是了。。转载,转载而己。
其实,如果用过apache的人,应该知道 ,在conf目录下,会有一个mimetype文件,里面其实就是一个对应表,当然,或许不全,但更当然的是,没有注释说明,只能自己凭感觉猜测了。。

既然有一个现成的,那当然还是备份下来以做参考:

描述 文件扩展名   MIME 类型
Text and Text-Related Types      
HTML text data (RFC 1866) html htm   text/html
Plain text: documents; program listings txt c c++ pl cc h   text/plain
Richtext (obsolete – replaced by text/enriched)     text/richtext
Structure enhanced text (etx?)   text/x-setext
Enriched text markup (RFC 1896)     text/enriched
Tab-separated values (tabular) (tsv?)   text/tab-separated-values
SGML documents (RFC 1874)     text/sgml
Speech synthesis data (MVP Solutions) talk   text/x-speech
       
Document Stylesheet Types      
Cascading Stylesheets css   text/css
DSSSL-online stylesheets     application/dsssl (proposed)
       
Image Types      
GIF gif   image/gif
X-Windows bitmap (b/w) xbm   image/x-xbitmap
X-Windows pixelmap (8-bit color) xpm   image/x-xpixmap
Portable Network Graphics png   image/x-png
Image Exchange Format (RFC 1314) ief   image/ief
JPEG jpeg jpg jpe   image/jpeg
TIFF tiff tif   image/tiff
RGB rgb   image/rgb
      image/x-rgb
Group III Fax (RFC 1494) g3f   image/g3fax
X Windowdump format xwd   image/x-xwindowdump
Macintosh PICT format pict   image/x-pict
PPM (UNIX PPM package) ppm   image/x-portable-pixmap
PGM (UNIX PPM package) pgm   image/x-portable-graymap
PBM (UNIX PPM package) pbm   image/x-portable-bitmap
PNM (UNIX PPM package) pnm   image/x-portable-anymap
Microsoft Windows bitmap bmp   image/x-ms-bmp
CMU raster ras   image/x-cmu-raster
Kodak Photo-CD pcd   image/x-photo-cd
Computer Graphics Metafile cgm   image/cgm
North Am. Presentation Layer Protocol     image/naplps
CALS Type 1 or 2 mil cal   image/x-cals
Fractal Image Format (Iterated Systems) fif   image/fif
QuickSilver active image (Micrografx) dsf   image/x-mgx-dsf
CMX vector image (Corel) cmx   image/x-cmx
Wavelet-compressed (Summus) wi   image/wavelet
AutoCad Drawing (SoftSource) dwg   image/vnd.dwg
      image/x-dwg
AutoCad DXF file (SoftSource) dxf   image/vnd.dxf
      image/x-dxf
Simple Vector Format (SoftSource) svf   image/vnd.svf
      also vector/x-svf
       
Audio/Voice/Music Related Types      
“basic”audio – 8-bit u-law PCM au snd   audio/basic
Macintosh audio format (AIpple) aif aiff aifc   audio/x-aiff
Microsoft audio wav   audio/x-wav
MPEG audio mpa abs mpega   audio/x-mpeg
MPEG-2 audio mp2a mpa2   audio/x-mpeg-2
compressed speech (Echo Speech Corp.) es   audio/echospeech
Toolvox speech audio (Voxware) vox   audio/voxware
RapidTransit compressed audio (Fast Man) lcc   application/fastman
Realaudio (Progressive Networks) ra ram   application/x-pn-realaudio
NIFF music notation data format     application/vnd.music-niff
MIDI music data mmid   x-music/x-midi
Koan music data (SSeyo) skp   application/vnd.koan
      application/x-koan
Speech synthesis data (MVP Solutions) talk   text/x-speech
       
Video Types      
MPEG video mpeg mpg mpe   video/mpeg
MPEG-2 video mpv2 mp2v   video/mpeg-2
Macintosh Quicktime qt mov   video/quicktime
Microsoft video avi   video/x-msvideo
SGI Movie format movie   video/x-sgi-movie
VDOlive streaming video (VDOnet) vdo   video/vdo
Vivo streaming video (Vivo software) viv   video/vnd.vivo
      video/vivo
Special HTTP/Web Application Types      
Proxy autoconfiguration (Netscape browsers) pac   application/x-ns-proxy-autoconfig
See Chapter 6     application/x-www-form-urlencoded
See Chapter 9     application/x-www-local-exec
See Chapter 9 (Netscape extension)     multipart/x-mixed-replace
See Chapter 9 and Appendix B     multipart/form-data
Netscape Cooltalk chat data (Netscape) ice   x-conference/x-cooltalk
Interactive chat (Ichat)     application/x-chat
       
Application Types      
       
Text-Related      
PostScript ai eps ps   application/postscript
Microsoft Rich Text Format rtf   application/rtf
Adobe Acrobat PDF pdf   application/pdf
      application/x-pdf
Maker Interchange Format (FrameMaker) mif   application/vnd.mif
      application/x-mif
Troff document t tr roff   application/x-troff
Troff document with MAN macros man   application/x-troff-man
Troff document with ME macros me   application/x-troff-me
Troff document with MS macros ms   application/x-troff-ms
LaTeX document latex   application/x-latex
Tex/LateX document tex   application/x-tex
GNU TexInfo document texinfo texi   application/x-texinfo
TeX dvi format dvi   application/x-dvi
MacWrite document ??   application/macwriteii
MS word document ??   application/msword
WordPerfect 5.1 document ??   application/wordperfect5.1
SGML application (RFC 1874)     application/sgml
Office Document Architecture oda   application/oda
Envoy Document evy   application/envoy
Wang Info. Tranfer Format (Wang)     application/wita
DEC Document Transfer Format (DEC)     application/dec-dx
IBM Document Content Architecture (IBM)     application/dca-rft
       
CommonGround Digital Paper (No Hands Software)     application/commonground
FrameMaker Documents (Frame) doc fm frm frame   application/vnd.framemaker
      application/x-framemaker
Remote printing at arbitrary printers (RFC 1486)     application/remote-printing
       
Archive/Compressed Archives      
Gnu tar format gtar   application/x-gtar
4.3BSD tar format tar   application/x-tar
POSIX tar format ustar   application/x-ustar
Old CPIO format bcpio   application/x-bcpio
POSIX CPIO format cpio   application/x-cpio
UNIX sh shell archive shar   application/x-shar
DOS/PC – Pkzipped archive zip   application/zip
Macintosh Binhexed archive hqx   application/mac-binhex40
Macintosh Stuffit Archive sit sea   application/x-stuffit
Fractal Image Format fif   application/fractals
Binary, UUencoded bin uu   application/octet-stream
PC executable exe   application/octet-stream
WAIS “sources” src wsrc   application/x-wais-source
NCSA HDF data format hdf   application/hdf
       
Downloadable Program/Scripts      
Javascript program js ls mocha   text/javascript
      application/x-javascript
VBScript program     text/vbscript
UNIX bourne shell program sh   application/x-sh
UNIX c-shell program csh   application/x-csh
Perl program pl   application/x-perl
Tcl (Tool Control Language) program tcl   application/x-tcl
Atomicmail program scripts (obsolete)     application/atomicmail
Slate documents – executable enclosures (BBN)     application/slate
Undefined binary data (often executable progs)     application/octet-stream
RISC OS Executable programs (ANT Limited)     application/riscos
       
Animation/Multimedia      
Andrew Toolkit inset     application/andrew-inset
FutureSplash vector animation (FutureWave) spl   application/futuresplash
mBED multimedia data (mBED) mbd   application/mbedlet
Macromedia Shockwave (Macromedia)     application/x-director
Sizzler real-time video/animation     application/x-sprite
PowerMedia multimedia (RadMedia) rad   application/x-rad-powermedia
       
Presentation      
PowerPoint presentation (Microsoft) ppz   application/mspowerpoint
PointPlus presentation data (Net Scene) css   application/x-pointplus
ASAP WordPower (Software Publishing Corp.) asp   application/x-asap
Astound Web Player multimedia data (GoldDisk) asn   application/astound
Special Embedded Object      
OLE script e.g. Visual Basic (Ncompass) axs   application/x-olescript
OLE Object (Microsoft/NCompass) ods   application/x-oleobject
OpenScape OLE/OCX objects (Business@Web) opp   x-form/x-openscape
Visual Basic objects (Amara) wba   application/x-webbasic
Specialized data entry forms (Alpha Software) frm   application/x-alpha-form
client-server objects (Wayfarer Communications) wfx   x-script/x-wfxclient
General Applications      
Undefined binary data (often executable progs)     application/octet-stream
CALS (U.S. D.O.D data format – RFC 1895)     application/cals-1840
Pointcast news data (Pointcast) pcn   application/x-pcn
Excel spreadsheet (Microsoft)     application/vnd.ms-excel
      application/x-msexcel
      application/ms-excel
PowerPoint (Microsoft) ppt   application/vnd.ms-powerpoint
      application/ms-powerpoint
Microsoft Project (Microsoft)     application/vnd.ms-project
Works data (Microsoft)     application/vnd.ms-works
MAPI data (Microsoft)     application/vnd.ms-tnef
Artgallery data (Microsoft)     application/vnd.artgalry
SourceView document (Dataware Electronics) svd   application/vnd.svd
Truedoc (Bitstream)     application/vnd.truedoc
Net Install – software install (20/20 Software) ins   application/x-net-install
Carbon Copy – remote control/access (Microcom) ccv   application/ccv
Spreadsheets (Visual Components) vts   workbook/formulaone
Cybercash digital money (Cybercash)     application/cybercash
Format for sending generic Macintosh files     application/applefile
Active message — connect to active mail app.     application/activemessage
X.400 mail message body part (RFC 1494)     application/x400-bp
USENET news message id (RFC 1036)     application/news-message-id
USENET news message (RFC 1036)     application/news-transmission
       
Multipart Types (mostly email)      
Messages with multiple parts     multipart/mixed
Messages with multiple, alternative parts     multipart/alternative
Message with multiple, related parts     multipart/related
Multiple parts are digests     multipart/digest
For reporting of email status (admin.)     multipart/report
Order of parts does not matter     multipart/parallel
Macintosh file data     multipart/appledouble
Aggregate messages; descriptor as header     multipart/header-set
Container for voice-mail     multipart/voice-message
HTML FORM data (see Ch. 9 and App. B)     multipart/form-data
Infinite multiparts – See Chapter 9 (Netscape)     multipart/x-mixed-replace
       
Message Types (mostly email)      
MIME message     message/rfc822
Partial message     message/partial
Message containing external references     message/external-body
Message containing USENET news     message/news
HTTP message     message/http
       
2D/3D Data/Virtual Reality Types      
VRML data file wrl vrml   x-world/x-vrml(changing to model/vrml)
WIRL – VRML data (VREAM) vrw   x-world/x-vream
Play3D 3d scene data (Play3D) p3d   application/x-p3d
Viscape Interactive 3d world data (Superscape) svr   x-world/x-svr
WebActive 3d data (Plastic Thought) wvr   x-world/x-wvr
QuickDraw3D scene data (Apple) 3dmf   x-world/x-3dmf
       
Scientific/Math/CAD Types      
Chemical types — to communicate information about chemical models     chemical/* (several subtypes)
Mathematica notebook ma   application/mathematica
Computational meshes for numerical simulations msh   x-model/x-mesh(evolving to model/mesh)
Vis5D 5-dimensional data v5d   application/vis5d
IGES models — CAD/CAM (CGM) data igs   application/iges(evolving to model/iges?)
Autocad WHIP vector drawings dwf   drawing/x-dwf
       
Largely Platform-Specific Types      
Silicon Graphics Specific Types      
Showcase Presentations showcase slides sc sho show   application/x-showcase
Insight Manual pages ins insight   application/x-insight
Iris Annotator data ano   application/x-annotator
Directory Viewer dir   application/x-dirview
Software License lic   application/x-enterlicense
Fax manager file faxmgr   application/x-fax-manager
Fax job data file faxmgrjob   application/x-fax-manager-job
IconBook data icnbk   application/x-iconbook
? wb   application/x-inpview
Installable software in ‘inst’ format inst   application/x-install
Mail folder mail   application/x-mailfolder
? pp ppages   application/x-ppages
Data for printer (via lpr) sgi-lpr   application/x-sgi-lpr
Software in ‘tardist’ format tardist   application/x-tardist
Software in compressed ‘tardist’ format ztardist   application/x-ztardist
WingZ spreadsheet wkz   application/x-wingz
Open Inventor 3-D scenes iv   graphics/x-inventor
       

来源:http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/appb/mimetype.html

我的来源就比较简单了:http://71j.cn/archives/21

来自google:优化网站的抓取与收录

一直以来,做站长的最关心的除了访问量和浏览量外,被搜索引擎收录量的多少也是众多站长的关注对象。

google adsense官网【adsense.googlechinablog.com,是官网吗?】好象一直在写这样的内容,比如今天就有了这个:优化网站的抓取与收录

内容不多,但有一个幻灯,还是去他们网站看吧。我这里只有内容哦

作者 Susan Moskwa, 网站管理员趋势分析员

很多有关于网站结构、抓取与收录、甚至是排名的问题都可以被归结为一个中心问题,那就是:搜索引擎能够多么容易的抓取您的网站?我们在最近的几次活动上都谈到过这个话题,下面您将会看到我们关于这个问题的演讲内容以及要点概括。

网络世界极其庞大;每时每刻都在产生新的内容。Google 本身的资源是有限的,当面对几近无穷无尽的网络内容的时候,Googlebot 只能找到和抓取其中一定比例的内容。然后,在我们已经抓取到的内容中,我们也只能索引其中的一部分。

URLs 就像网站和搜索引擎抓取工具之间的桥梁: 为了能够抓取到您网站的内容,抓取工具需要能够找到并跨越这些桥梁(也就是找到并抓取您的URLs)。如果您的URLs很复杂或冗长,抓取工具不得不需要 反复花时间去跟踪这些网址;如果您的URLs很规整并且直接指向您的独特内容,抓取工具就可以把精力放在了解您的内容上,而不是白白花在抓取空网页或被不 同的URLs指引却最终只是抓取到了相同的重复内容。

上面的幻灯片【幻灯地址在下面,请单独开窗查看】上,您可以看到一些我们应当避免的反例--这些都是现实中存在的 URL例子(尽管他们的名称由于保护隐私的原因已经被替换了),这些例子包括被黑的URL和编码,冗余的参数伪装成URL路径的一部分,无限的抓取空间, 等等。您还可以找到帮助您理顺这些网址迷宫和帮助抓取工具更快更好地找到您的内容的一些建议,主要包括:

  • 去除URL中的用户相关参数。那 些不会对网页内容产生影响的URL中的参数——例如session ID或者排序参数——是可以从URL中去除的,并被cookie记录的。通过将这些信息加入cookie,然后301重定向至一个“干净”的URL,你可 以保持原有的内容,并减少多个URL指向同一内容的情况。
  • 控制无限空间。你的网站上是否有一个日历表,上面的链接指向无 数个过去和将来的日期(每一个链接地址都独一无二)?你的网页地址是否在加入一个&page=3563的参数之后,仍然可以返回200代码,哪怕 根本没有这么多页?如果是这样的话,你的网站上就出现了所谓的“无限空间”,这种情况会浪费抓取机器人和你的网站的带宽。如何控制好“无限空间”,参考这 里的一些技巧吧。
  • 阻止Google爬虫抓取他们不能处理的页面。通 过使用你的robots.txt 文件,你可以阻止你的登录页面,联系方式,购物车以及其他一些爬虫不能处理的页面被抓取。(爬虫是以他的吝啬和害羞而著名,所以一般他们不会自己 “往购物车里添加货物” 或者 “联系我们”)。通过这种方式,你可以让爬虫花费更多的时间抓取你的网站上他们能够处理的内容。
  • 一人一票。 一个 URL, 一段内容。在 理想的世界里,URL和内容之间有着一对一的对应:每一个URL会对应一段独特的内容,而每一段内容只能通过唯一的一个URL访问。越接近这样的理想状 况,你的网站会越容易被抓取和收录。如果你的内容管理系统或者目前的网站建立让它实现起来比较困难,你可以尝试使用rel=canonical元素去设定 你想用的URL去指示某个特定的内容。
原文: Optimize your crawling & indexing
幻灯的地址为:http://docs.google.com/present/view?id=dg3m4jk5_464c3c3vpcg
感觉还行,随便看看吧。英文版的哦。

啊兴的更新

啊兴,很多人都不熟悉这个网名,但在hiapk网站,如果说不知道啊兴,那一定是刚刚去这个论坛的人。
啊兴做了很多ROM,g1,g2,g3,目前我用的就是啊兴的G2ROM,这两天上hiapk发现他又升级了。

这次升级对我来说,只关心一件事,那就是HOME变成5屏了。原来只有3屏。。。

真开心啊。。筒子们,快去下载,不过。。。啊兴也说了:

XML/HTML代码
  1. 为了方便大家对 ROM 的情况一目了然,简单说明一下以后 ROM 版本的区分。小数点后面是奇数的为测试抢鲜版,小数点后面是偶数的为正式稳定版。这样大家就可以各取所需了。现在 ROM 的更新越来越快,靠我自己已经完全测试不完整了。  

 

如果有兴趣,可以刷一下2.9版的ROM:http://www.hiapk.com/bbs/thread-39386-1-2.html

 【更新:现在是晚上11点,我在一次意外的重启后,再也无法进入系统,目前又把ROM刷回原来的2.581了。刚刚结束。做个记号,睡觉了】

Tags: google, htc, g2, rom

王者归来?

说起PHP的模版引擎,大多数人第一个就会想起smarty,但是随着PHP的发展,而smarty一直在兼顾着老版本的PHP,慢慢的,慢慢的也就没落了。。。

 

如今,他好象又准备回来了。你看:
Yes, yes I know. The Smarty 3 beta is taking much longer than expected, but we wanted to be sure we had everything right. Our preliminary performance tests are already showing us very promising speed improvements over Smarty 2 (2-5x on average), and we're not done! To recap, Smarty 3 is a 100% rewrite from the ground up, and it is PHP 5 only. We will be getting a feature list up with the Beta, but let me give a quick summary:

 

  • PHP5 OO design
  • SPEED
  • Object Chaining
  • Exception Error Handling
  • Assigned Data Objects
  • Multiple Template Objects
  • Static Object Access
  • Pure PHP Template Option
  • Powerful Parser/Lexer
  • Tons of Template Syntax Enhancements
  • Improved Data Scoping Features
  • Variable Filters (ie. auto-html-escape)
  • In-template Functions (easy recursion)
  • Template Inheritance
  • PHP Streams Support (per template/variable/include)
  • Smart javascript/css handling (no more {literal} tags)
  • Improved Cache handling (per template/variable/function)
  • Many other things too numerous!

There are many folks using the Alpha in production, and with this feedback we feel the Beta is going to be very stable to begin with. Feel free to grab the Alpha and give it a test! We want feedback!

You can checkout Smarty 3 Alpha with SVN:
svn checkout http://smarty-php.googlecode.com/svn/branches/Smarty3Alpha/

想知道更多的信息?去http://www.smarty.net去看吧。也可以订阅他们的maillist哦。