zoukankan      html  css  js  c++  java
  • SpringBoot之GZip压缩,HTTP/2,文件上传,缓存配置

    1 设置应用端口以及context

    # HTTP Server port
    server.port=8080
    
    # Make the application accessible on the given context path (http://localhost:8080/myapp)
    server.servlet.context-path=/myapp
    

    2 启用Gzip压缩

    # Enable response compression
    server.compression.enabled=true
    
    # The comma-separated list of mime types that should be compressed
    server.compression.mime-types=text/html,text/xml,text/plain,text/css,text/javascript,application/javascript,application/json
    
    # Compress the response only if the response size is at least 1KB
    server.compression.min-response-size=1024
    

    3 启用HTTP/2支持

    # Enable HTTP/2 support, if the current environment supports it
    server.http2.enabled=true
    

    4 缓存静态文件

    # Maximum time the response should be cached (in seconds) 
    spring.resources.cache.cachecontrol.max-age=120
    
    # The cache must re-validate stale resources with the server. Any expired resources must not be used without re-validating.
    spring.resources.cache.cachecontrol.must-revalidate=true
    

    5 文件上传支持

    spring.servlet.multipart.enabled=true
    
    # Write files to disk if the file size is more than 2KB.
    spring.servlet.multipart.file-size-threshold=2KB
    
    # The intermediate disk location where the uploaded files are written
    spring.servlet.multipart.location=/tmp
    
    # Maximum file size that can be uploaded
    spring.servlet.multipart.max-file-size=50MB
    
    # Maximum allowed multipart request size
    spring.servlet.multipart.max-request-size=75MB
    

    PS:
    如果您觉得我的文章对您有帮助,请关注我的微信公众号,谢谢!
    程序员打怪之路

  • 相关阅读:
    349. 两个数组的交集
    383. 赎金信
    242. 有效的字母异位词
    844. 比较含退格的字符串
    904. 水果成篮
    剑指offer(9)变态跳台阶
    剑指offer(8)跳台阶
    剑指offer(7)斐波那契数列
    剑指offer(6)旋转数组的最小数字
    剑指offer(5)用两个栈实现队列
  • 原文地址:https://www.cnblogs.com/jason1990/p/10569575.html
Copyright © 2011-2022 走看看