I have written an asp.net http handler that returns javascript. When including a script tag on html page that references this handler, chrome/firefox is not reporting the cache-control:max-age header being returned unless a querystring (or '?') is present in the script tag src. Thus the handler is being hit every time. This is happening in both firefox and chrome.
Here is the handler implementation:
Public Overrides Async Function ProcessRequestAsync(context As HttpContext) As Task
Dim loader As New ScriptLoader(context)
Dim sb As New StringBuilder()
sb.Append(Await loader.GetScriptsAsync())
sb.Append(loader.GetLoaderScript("engine"))
sb.Append(loader.GetLoaderScript("styles"))
Dim script As String = sb.ToString()
context.Response.ContentType = "application/javascript"
context.Response.Cache.SetCacheability(HttpCacheability.Public)
context.Response.Cache.SetMaxAge(TimeSpan.FromHours(12))
context.Response.Write(script)
End Function
HTML script tag:
<div>
<script src="/ListingDisplay/loader/js"></script>
</div>
Results: https://i.ibb.co/hK8TQJ3/Capture.png
When I append a "?" on the script source:
<div>
<script src="/ListingDisplay/loader/js?"></script>
</div>
I get the expected results, and the handler is not hit on subsequent requests:
Expected Result: https://i.ibb.co/x8S3W3v/Capture.png
Anyone ever seen this? Any ideas?