Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8736489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:18:46+00:00 2026-06-13T10:18:46+00:00

I use varnish cache some file like *.doc *.png *.xls. It work well while

  • 0

I use varnish cache some file like *.doc *.png *.xls.

It work well while I get files from cache but *.xls.

My URI is like /attachment/show?fileId=ewer232ewe2121eeddsd. When I request a .xls file from cache, it will return a file named show whitout extension.

My server code is:

if (StringUtil.null2Trim(attachment.getExtension()).equals("doc")
                    || StringUtil.null2Trim(attachment.getExtension()).equals("docx")
                    || StringUtil.null2Trim(attachment.getExtension()).equals("xlsx")
                    || StringUtil.null2Trim(attachment.getExtension()).equals("xls")) {
                response.setHeader("Content-Disposition", "attachment; filename=\""
                        + StringUtil.gbk2Iso(attachment.getName()) + "\"");
                if (StringUtil.null2Trim(attachment.getExtension()).indexOf("doc") != -1) {
                    response.setContentType("application/msword");
                }
                if (StringUtil.null2Trim(attachment.getExtension()).indexOf("xls") != -1) {
                    response.setContentType("application/vnd.ms-excel");
                }

            } else {
                if (StringUtil.null2Trim(attachment.getExtension()).equals("jpg")) {
                    response.setContentType("image/jpeg");
                } else if (StringUtil.null2Trim(attachment.getExtension()).equals("png")) {
                    response.setContentType("image/x-png");
                } else {
                    response.setContentType("image/" + attachment.getExtension());
                }
            }

My question is:Why can’t I get the correct file full name like attachment.getName()+".xls", and how to solve it.

PS: Is there any way to set ContentType in varnish(vcl)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:18:47+00:00Added an answer on June 13, 2026 at 10:18 am

    Let me answer the last question; you can override any HTTP response header in Varnish.

    Use the following VCL snippet:

    sub vcl_fetch {
        if (req.url ~ ".xls$") {
            set beresp.http.content-type = "application/vnd.ms-excel";
        }
    }
    

    In general you can add and remove headers at will by doing “set beresp.http.XXX = YYY;” or “unset beresp.http.XXX;” in vcl_fetch.

    For your main question, I’d explore if adding a MIME envelope (header example here) helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use Varnish-cache to cache some of the dependancies of my
We use varnish as our load balancer (among other things) but we get some
use C#,want to upload excel file on google doc. bellow syntax use to upload
My goal is to use Varnish to cache my static assets with my Symfony
I want to use Varnish to cache certain pages even in the presence of
Varnish 2.1: I'm trying to use http PURGE to get Varnish to renew one
I'm trying to use the varnish caching with symfony2. Setup is Varnish -> NGNIX
I try to configure varnish so it can handle jsonp. I use as the
I am using Varnish 3.0.3 and to use it to leverage browser caching by
I am a bit confused about the purpose of Varnish and Rack-Cache for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.