开发者

301 Redirect with htaccess and Cache: How to Delete Old Cache?

So after much help and research I've FINALLY been able to get the 301 redirects working via .hta开发者_运维百科ccess file, but I noticed that unless I actually hit 'refresh' on my browser it will not redirect the page due to simply reading the cached site.

I've tried closing all browsers, inserting the .htaccess file, and THEN opening a new browser, but it still opens the cached site. I would hazard a guess that most customers will not bother refreshing a page, and if they do not, this will take quite a while to discover that there is indeed a new page!

Any ideas? Thanks!

-Karl

EDIT: I just had the idea of putting a link on our current homepage that says, "Click here to see our new website!" and the link will refresh the page, which will in turn kick the 301 redirect into action. Can anyone think of any negative side-effects of this?


Karl,

The best way I've found to examine caching headers is the Live HTTP Headers firefox add on.

This is what it says about your homepage:

HTTP/1.x 200 OK
Date: Fri, 06 Nov 2009 15:16:57 GMT
Server: Apache
Last-Modified: Mon, 12 Oct 2009 16:52:05 GMT
Etag: "85dcc1-1386-4ad35eb5"
Accept-Ranges: bytes
Content-Length: 4998
Keep-Alive: timeout=10, max=99
Connection: Keep-Alive
Content-Type: text/html

As mentioned above, the etag is the issue. A quick (unixy) fix might be: find /var/www/htdocs -type f|xargs touch which will change the modified time of every file in your www directory.

It does, however, depend on how your apache instance is configured to generate the etag value. Here's a great little howto on setting up caching with Apache.

As far as your suggestion to add a link, I don't think that will work. You can't force a browser to refresh a page remotely, and, as pointed out above, the issue is with the etags, which your solution won't change.

Dan


Wait a while. Most users caches will expire in a period of hours, unless you set the server to serve the page with an unusually long cache hint.

If you're serving the page now, you can set headers so that the client does not cache it. See this question for that:

What is the proper way to tell the browser not to cache?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜