title: Webpack / React/ Spring Boot: caching bundle.js with https
body: <p>In my Spring-Boot/React application, i want to cache <code>bundle.js</code>(1.2Mb). If i run the app with <code>http://(test-envionment-server-url)/myapp</code>, my <code>bundle.js</code> get called from cache (208 B) with HTTP status 304 every time i refresh the page. Until now everything is fine.</p>
  
  <p>But when i use <code>https://(test-envionment-server-url)/myapp</code>, <code>bundle.js</code> is not cached and each time i refresh it gets all 1.2Mb, yet all other images and font get cached.</p>
  
  <p>I am using Tomcat in local, and JBoss 7.0.x in my test environment.</p>
  
  <p>Here is my <code>webpack.config.js</code></p>
  
  <pre><code>const webpack = require('webpack');
  const autoprefixer = require('autoprefixer');
  
  module.exports = {
    cache: true,
    entry: [
      'webpack-dev-server/client?http://localhost:8008',
      'webpack/hot/only-dev-server',
      'babel-polyfill',
      './src/index.js',
    ],
    module: {
      loaders: [
      {
        test: /\.jsx?$/,
        exclude: /node_modules/,
        loader: 'react-hot!babel',
      },
      {
        test: /\.(jpe?g|png|gif|svg)$/i,
        loaders: [
          'url?limit=2048',
          'img',
        ],
      },
      {
        test: /\.(woff|woff2|eot|ttf)$/,
        loader: 'url-loader?limit=2048',
      },
      {
        test: /\.scss$/,
        loaders: ['style', 'css', 'postcss-loader', 'sass'],
      },
      ],
    },
    resolve: {
      extensions: ['', '.js', '.jsx'],
    },
    output: {
      path:`${__dirname}/(spring-boot-app-url/resources/static`,
      publicPath: '/publicpath/',
      filename: 'bundle.js',
    },
    devServer: {
      port: 8008,
      contentBase: './dist',
      historyApiFallback: true,
      hot: true,
      proxy: {
        .....(proxy config)
      },
    },
  },
  },
  postcss: () =&gt; {
    return [autoprefixer];
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.optimize.UglifyJsPlugin(),
    new webpack.optimize.DedupePlugin(),
    new webpack.DefinePlugin({
    'process.env': {
      'NODE_ENV': JSON.stringify('production'),
    },
  }),
  ],
  };
  </code></pre>
  
  <p>in my Spring i have some Spring security configuration:</p>
  
  <pre><code>@Override
  protected void configure(HttpSecurity httpSecurity) throws Exception {
      httpSecurity
  
              .csrf().disable()
  
              .authorizeRequests()
              .antMatchers(TOKEN_NAME).permitAll() // API
              ...(antMatchers)
              .and()
              .authorizeRequests()
              .antMatchers(TOKEN_BASED_AUTH_ENTRY_POINT).permitAll();
  
      httpSecurity
              .addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
  
      httpSecurity.headers().cacheControl().disable();
  }
  </code></pre>
  
  <p>Here is the Request header from my Network tab:  </p>
  
  <pre><code> Accept:*/*
   Accept-Encoding:gzip, deflate, sdch, br
   Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
   Connection:keep-alive
   Host:*****
   Referer:https://****/appname/
   User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
  </code></pre>
  
  <p>Here is the Response header from Network tab:</p>
  
  <pre><code>Accept-Ranges:bytes
  Cache-Control:max-age=3600
  Connection:keep-alive
  Content-Length:1248915
  Content-Type:application/javascript; charset=UTF-8
  Date:Mon, 05 Dec 2016 12:56:47 GMT
  Last-Modified:Mon, 05 Dec 2016 09:08:06 GMT
  Server:JBoss-EAP/7
  Strict-Transport-Security:max-age=31536000 ; includeSubDomains
  X-Content-Type-Options:nosniff
  X-Frame-Options:DENY
  X-Powered-By:Undertow/1
  X-XSS-Protection:1; mode=block
  </code></pre>
  
  <p>When i run it with <strong>http</strong> url, the header request doesn't have any cache control.
  Any idea about how to cache <code>bundle.js</code> file even when i run my app using <strong>https</strong>?</p>
  
  <p>Thank you</p>