1

I analyzed my website, and appear this error "No expiration time specified" for files .css, .js, .png, .jpg, etc.

I've found this for php

<IfModule mod_headers.c>
<FilesMatch "\.(jpg|jpeg|png|gif|swf|js|css|swf)$">
    Header set Cache-Control "max-age=604800, public"
</FilesMatch>

What is the equivalence in C#? and, should I code this in web.config?

Thanks in advance.

1 Answer 1

2

You need to set clientCache in staticContent block of your IIS Config.

<system.webServer>
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
    </staticContent>
  </system.webServer>

This sets the expiry for 30 days.

Detailed explaination can be found here.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much, This work fine! @NutcaseDeveloper

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.