0

I added a logo image to navbar menu in my MVC Core project. It's about 5k. But it loads in every page log, which is a waste. Is there any suggestion how to cache the image file in browser. Do I have to use output cache?

Sharon Zhou
  • 61
  • 1
  • 4
  • You can put this logo image in `_Layout.cshtml` since you want to show this logo on every page. And when you navigate the pages, you should see that this image is `from memory cache` – shiming Jan 07 '19 at 04:13
  • I understand you're talking about doughnut hole cache that cache the layout page, but I'm not sure if MVC Core support that. The logo is already in _Layout.cshtml. I just noticed every time when a page shows, the image got an 200 code. If it's cached, the code should be 304. – Sharon Zhou Jan 07 '19 at 05:22
  • Please see this site, somehow the logo image is reloaded everytime. https://www.softblog.ca/ – Sharon Zhou Jan 07 '19 at 05:30
  • Sorry I mean doughnut cache – Sharon Zhou Jan 07 '19 at 05:38
  • I checked the site link u gave and the developer tool shows that it is already 'from memory cache'. For the 200 and 304, here is a link [Cache with 200 and 304](https://stackoverflow.com/questions/1665082/what-is-the-difference-between-http-status-code-200-cache-vs-status-code-304) – shiming Jan 07 '19 at 06:44
  • I think for your case, the expected status code should be 200 instead of 304 as a logo can be cached by the browser – shiming Jan 07 '19 at 06:52

0 Answers0