如何刷新laravel模板和禁用缓存


How to refresh laravel template and disable caching?

嘿,伙计们,我只是在玩laravel,基本上有以下视图:

<!doctype html>
<html class="no-js" lang="">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="x-ua-compatible" content="ie=edge">
        <title>Title</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="apple-touch-icon" href="apple-touch-icon.png">
        <!-- Place favicon.ico in the root directory -->
        <link rel="stylesheet" href="css/normalize.css">
        <link rel="stylesheet" href="css/style.css">
        <style>
            h1 {
                color: #727272;
                font: bold 2em/1.4 verdana;
            }
            .nav-items {
                padding: 0;
                margin: 0;
                list-style-type: none;
            }
            .nav-items li {
                display: inline-block;
                margin-right: 10px;
                padding: 1em 1.5em;
                border: 1px solid #ccc;
                background-color: #eee;
                -webkit-box-shadow: 0 0 2px rgba(0,0,0,.2);
                box-shadow: 0 0 2px rgba(0,0,0,.2);
                color: #727272;
                text-shadow: 0 0 1px rgba(255,255,255,1);
            }
        </style>
    </head>
    <body>
        <!--[if lt IE 8]>
<p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

           <ul class="nav-items">
               @foreach($categories as $category)
                   <li>
                       Category id is {{ $category-> id }} 
                   </li> 
               @endforeach  
            </ul>

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.3.min.js"><'/script>')</script>
    </body>
</html>

现在假设我改变下面的代码:

<ul class="nav-items">
               @foreach($categories as $category)
                   <li>
                       Category id is {{ $category-> id }} 
                   </li> 
               @endforeach  
 </ul>

到以下:

<ul class="nav-items">
               @foreach($categories as $category)
                   <li>
                       Product id is {{ $category-> id }} // I have only changed the word "Categories" to "Products"
                   </li> 
               @endforeach  
 </ul>

我只将单词Categories更改为Products,但是当我的视图加载到浏览器中时,我仍然看到单词"Category"而不是"Products"。

我目前唯一的解决方案是改变视图文件名,然后在控制器中改变视图名称,这是非常不方便的!这个问题还有别的解决办法吗?这与缓存有关吗?

注:我在SO上看过几个关于这个话题的帖子,他们没有解决我的问题。

Laravel会将模板文件编译为php文件来缓存它。您可以使用以下命令清除缓存:

php artisan cache:clear

我遇到了同样的问题。我使用laragon apache服务器。我所做的是关闭apache服务器并开始使用php artisan serve命令。似乎apache负责缓存我的文件。:)