프론트엔드/Javascript

브라우저 캐시(cache) 지우기

짱구를왜말려? 2021. 2. 9. 01:17
반응형
SMALL

# What?

- axios로 기존 데이터 안쓰고 갱신하게 처리(데이터 삭제 후 뒤로가기하면 삭제된 데이터를 포함한 목록데이터가 남는다던지

 

- view단 캐시도 안남게 하기

 

# How?

@ bootstrap.js

...
window.axios = require('axios');
window.axios.defaults.headers["Cache-Control"] = "no-cache";
window.axios.defaults.headers["Pragma"] = "no-cache";
window.axios.defaults.headers["Expires"] = "0";
...

@ app.blade.php

@php
    header('Cache-Control: no-cache, no-store, must-revalidate'); // HTTP 1.1.
    header('Pragma: no-cache'); // HTTP 1.0.
    header('Expires: 0'); // Proxies.
@endphp
<!doctype html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>{{ config('app.name', 'Laravel') }}</title>
    <script src="{{asset('js/jquery-3.5.1.min.js')}}"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.min.js" ></script>
    <script type="text/javascript" src="https://cdn.iamport.kr/js/iamport.payment-1.1.5.js"></script>

    <!-- Styles -->
    <link href="{{ asset('css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('css/default.css') }}" rel="stylesheet">
    <link href="{{ asset('css/style.css') }}" rel="stylesheet">
</head>
<body>
<div id="app">
    @include("components.header")

    <div id="container">
        @yield("content")
    </div>

    @include("components.footer")
</div>
<script src="{{asset("js/app.js")}}">
    window.user = "{{auth()->user()}}";
</script>
</body>
</html>




LIST