Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static files are treated as dynamic content and therefore not served from cache #2

Open
Phoenix359 opened this issue Mar 20, 2019 · 5 comments
Labels
help wanted Extra attention is needed

Comments

@Phoenix359
Copy link
Contributor

IIS on Azure is either not caching the crompessed static files after a request or it is not serving them from the cached location on subsequent requests. I have tryed to set the "directory" tag with the most common value in the applicationHost.xdt but that did not work.

Old:
<httpCompression>

New:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">

@shibayan
Copy link
Owner

No configuration is required as XDT retains the App Service default settings.

image

@Phoenix359
Copy link
Contributor Author

Thx for the fast reponse!

I did some extra digging and found out that my static files are not identified as static at all. The request:
GET app.bundle.min.js?v=69YZmh... is treated as dynamic content and therefore is compressed with the lvl set by the dynamicCompressionLevel attribute and is not added to the cache.
I tryed to remove the two javascript mimeTypes from the dynamicTypes node but then no compression is being performed. I tryed to add the element:
<urlCompression doStaticCompression="true" doDynamicCompression="true" />
but that did not help either. I now suspect that the cache busting query string is causing IIS to see this as dynamice content. Is this something this extension can help with or do i need to call on the azure CDN to help me cache my static (versioned) content?

@shibayan
Copy link
Owner

IIS static content compression may only be used for frequently accessed files.
It may not be working properly with App Service in the first place. Possibly another problem with brotil compression.

@shibayan shibayan added the help wanted Extra attention is needed label Mar 25, 2019
@Phoenix359
Copy link
Contributor Author

I now partially solved this issue by pre-compressing (Gzip & Brotli) all my static files on build with some Gulp tasks and use the nuget package CompressedStaticFiles to serve these pre-compressed static files.
These files are probably not served from server cache but i can leverage Azure CDN for that.

For the dynamic content compression i still use this extension.

@Phoenix359 Phoenix359 changed the title Compressed static files are not cached/served from cache Static files are treated as dynamic content and therefore not served from cache Jun 5, 2019
@franzo
Copy link

franzo commented Oct 27, 2021

adding a rewrite rule to strip the query string works around the issue, e.g.

<rule name="Strip query string to allow static compression" stopProcessing="true">
    <match url="^static/css/(.*)" />
    <action type="Rewrite" url="{PATH_INFO}" appendQueryString="false" />
</rule>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants