使用nginx设置静态内容的过期标题

时间:2018-12-13 12:38:15

标签: nginx caching

我在Glassfish(Java应用程序服务器)前面使用Nginx来提供我的静态内容。我正在使用以下设置来设置到期标头

import React, { Component } from 'react';
import Wavesurfer from 'react-wavesurfer';
window.WaveSurfer = require("wavesurfer.js");
let Regions = require("react-wavesurfer/lib/plugins/regions").default;
let Minimap = require("react-wavesurfer/lib/plugins/minimap").default;


class Recording extends Component {
  constructor(props) {
    this.state = {
      pos: 0,
    }
    this.handleTogglePlay = this.handleTogglePlay.bind(this);
    this.handlePosChange = this.handlePosChange.bind(this);
  }
  handleTogglePlay() {
    const { id, onChange } = this.props;
    onChange(id);
  }
  handlePosChange(e) {
    this.setState({
      pos: e.originalArgs[0]
    });
  }
  render() {
    const { data } = this.props;
    return (
      <li className="list-group-item">
         <Wavesurfer
           audioFile={data.comment_url}
           pos={this.state.pos}
           onPosChange={this.handlePosChange}
           playing={this.props.playing}
         />
         <button onClick={this.handleTogglePlay}>play</button>
      </li>
    );
  }  
}
class DashboardPage extends Component{
   constructor(props){
    super(props);
    this.state = {
      playing: -1,
      recordings:objectOfRecordings,
    };
    this.handleChange = this.handleChange.bind(this);
    this.changePlaying = this.changePlaying.bind(this);
   };

   changePlaying(id) {
     this.setState({
       playing: id,
     });
   }

   render(){
    const { recordings } = this.state;
    return(
        <div>
          <h1>Dashboard</h1>          
          <div className="recording">
            <ul className="list-group">
            {
              recordings &&
              recordings.map((prop,key)=>{
                return (
                  <Recording 
                    data={prop}
                    key={key}
                    id={key}
                    playing={key === this.state.playing}
                    onChange={this.changePlaying}
                  />
                )

              })
            }
            </ul>
          </div>
        </div>
    );
  }
}

我在location /javax.faces.resource/images/ { proxy_pass http://xx.xxx.xx:8080/javax.faces.resource/images/; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; expires 365d; add_header Pragma public; add_header Cache-Control "public"; } 中也有CSS和JS文件,并且想要设置另一个到期标头。如何在不破坏图像设置的情况下实现这一目标?

另一个问题:我注意到有时Response标头中有许多/javax.faces.resource/条目。
是否可以重置属性而不是使用Cache-Control
谢谢
编辑

add_header

0 个答案:

没有答案