Heim  >  Artikel  >  Backend-Entwicklung  >  静态化 - PHP静态页如何显示最新新闻

静态化 - PHP静态页如何显示最新新闻

WBOY
WBOYOriginal
2016-06-06 20:37:44986Durchsuche

比如我有一个静态页面,基于phpcms系统,页面是新闻内容页,我想做个“最新新闻”模块,因为是静态页面不能及时显示最新文章吧,我想到几个办法:1.频繁的全站生成所有页面,但是太麻烦又耗时 2.用一个iframe引用一个动态页,这个动态页显示最新新闻 3.用ajax请求最新新闻显示出来

一般做法是哪种,或者有更好的办法?不吝赐教!

页面举例:http://www.dayecn.com/science/2244.html

回复内容:

比如我有一个静态页面,基于phpcms系统,页面是新闻内容页,我想做个“最新新闻”模块,因为是静态页面不能及时显示最新文章吧,我想到几个办法:1.频繁的全站生成所有页面,但是太麻烦又耗时 2.用一个iframe引用一个动态页,这个动态页显示最新新闻 3.用ajax请求最新新闻显示出来

一般做法是哪种,或者有更好的办法?不吝赐教!

页面举例:http://www.dayecn.com/science/2244.html

http://news.sina.com.cn/c/2015-02-28/024431550484.shtml
看了新浪新闻右侧的热点博客,是用的ifrmae

本质就是不同的缓存策略共存问题

script:src嵌入是另一种方案

这里面iframe基本上是灾难应该淘汰。
Ajax代码相对复杂,速度也比不过script:src(需要等js运行才发请求),不建议。

剩下的script:src和静态生成各有所长,看情况吧(其实也可以组合的,script:src的链接可以是另一份静态生产的内容……)

ssi

shtml

pls google it!~

搞这么麻烦
include 'your_latest_news.file';
然后cron job 每隔多长时间generate这个your_latest_news.file

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn