Open Closed

Remove Cache-Control header #10449

mahendra created


  • What is your product type (Angular or MVC)?
  • Angular
  • What is product framework type (.net framework or .net core)?
  • .net core

Hi Experts,

We have hosted our zero web application(.net core + angular) on AWS Beanstalk-LINUX based node.js environment. We have a requirement to change the Cache-control to max-size = 31536000. As our angular application hosted on AWS Beanstalk-LINUX based node.js environment, With the help of the AWS support we are able to achieve the same using the below nginx.conf file.

---------nginx.conf Start---------------------------------------------------------------------

`#Elastic Beanstalk Nginx Configuration File

user nginx; errorlog /var/log/nginx/error.log warn; pid /var/run/; workerprocesses auto; workerrlimitnofile 32633;

events { workerconnections 1024; }

http { include /etc/nginx/mime.types; defaulttype application/octet-stream;

logformat  main  '$remoteaddr - $remoteuser [$timelocal] "$request" '
                  '$status $bodybytessent "$httpreferer" '
                  '"$httpuseragent" "$httpxforwardedfor"';

include       conf.d/.conf;

map $httpupgrade $connectionupgrade {
    default     "upgrade";


Map blocks to set value of $control and $expires variable based on the $uri

map $cache $control { 1 "public"; }

map $cache $expires { 1 31536000; default off; # or some other default value }

map $uri $cache { ~.(js|css|png|jpe?g|gif|ico)$ 1; } #----------------------------------------------------------------

server {
    listen        80 defaultserver;
    accesslog    /var/log/nginx/access.log main;

    clientheadertimeout 60;
    clientbodytimeout   60;
    keepalivetimeout     60;
    gzip                  off;
    gzipcomplevel       4;
    gziptypes text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
   # Adding Cache-Control headers
   addheader Cache-Control "$control,max-age=$expires";

    # Include the Elastic Beanstalk generated location
    include conf.d/elasticbeanstalk/.conf;


------------nginx.conf End-------------------------------------------------------

Now as you can see in the below screen shot that cache-control max-size is set to 31536000. However we are also getting the cache-control:public, max-age=0.

As per AWS support, these response headers are coming from application itself and we are not aware from where in our aspnet zero application we are setting these response headers or how to remove them.

Could you please help us in removing the cache-control response header with the max-age=0.

We also checked the below option. But visual studio does not recognize the DefaultResponseCacheAttributeForAppServices/ DefaultResponseCacheAttributeForControllers

Any help would be much appreciated.

Thanks, Regards

3 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @mahendra

    Could you please follow We will work on this in a short time.

  • 0
    mahendra created

    hi ismcagdas,

    Thanks for your response.

    I have gone through the link shared by you. Just to let you know that we use the services. Might be the framework itself would be creating the controller based on the naming convention.

    Currently we are using aspnetboilerplate version 5.2 and .Net Core 3.1. As we are about to release our product in near future. Therefore, it may take some time for us to upgrade to the latest aspnetboilerplate version + .Net 5.

    We also noticed in that link that even after upgrading to the latest version issue is still open.

    Could you please give us your sincere opinion how to proceed?

    Thanks, Best Regards,

  • 0
    ismcagdas created
    Support Team

    Hi @mahendra

    You don't have to upgrade your solution to latest ABP version. We will try to provide a solution without upgrading the NuGet packages. I assume this issue will be resolved until the end of this month.