如何强制清理浏览器缓存Laravel [英] How to force clean browser cache laravel

查看:417
本文介绍了如何强制清理浏览器缓存Laravel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Web开发的新手.我只想问一下如何使用 PHP 强制清除浏览器中的所有缓存.

Im new in web development. I just want to ask if how to force clean all cache in the browser using PHP.

推荐答案

您能做的最好的事情是设置一个缓存控制标头,但是您不能使用服务器端语言在客户端上强制"执行任何操作.

The best you can do is set a cache-control header, but you cannot "force" anything on client with a server-side language.

在laravel中:

return view('some_template')->header('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0');

在普通的php中,您将在输出任何内容之前使用header()函数.

In plain php you would use header() function before outputting anything.

header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0');

这篇关于如何强制清理浏览器缓存Laravel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆