http-caching

MVC3 OutputCache not working on Server and Client as expected

情到浓时终转凉″ 提交于 2019-12-04 06:11:40
I'm having trouble using the OutputCache attribute in Microsoft's MVC3 framework. Please imagine the following controller action, which can be used as part of an AJAX call to get a list of products based on a particular manufacturerId: public JsonResult GetProducts(long manufacturerId) { return Json(this.CreateProductList(manufacturerId), JsonRequestBehavior.AllowGet); } I want this result to be cached on the server to avoid making excessive database queries. I can achieve this by configuring the attribute thus: [OutputCache(Duration = 3600, Location = OutputCacheLocation.Server, VaryByParam =

Caching search result in Web API

家住魔仙堡 提交于 2019-12-04 05:59:57
问题 I am caching Get method in webapi with strathweb,now i want to use same cached output in my another webapi method Search .So how to access cached Get result in Search Method?How to find Cache Key to use it in another methods? [CacheOutput(ClientTimeSpan = 300, ServerTimeSpan = 300)] public IEnumerable<Movie> Get() { return repository.GetEmployees().OrderBy(c => c.MovieId); } 回答1: Rather than using the OutputCache , you could consider using MemoryCache to store your results in memory for

Leverage browser caching

99封情书 提交于 2019-12-04 04:23:56
问题 I have a website and when I check page speed with Google plug-in, I receive: Leverage browser caching The following resources are missing a cache expiration Searching only returns information on using htaccess under Apache, but my site is running on Windows 2003 Server, in plain HTML language, and I don't even have access to the server. Is there any way to specify expiration and gzip compression, as it recommends? 回答1: Have a look at Content Expiration, that should do the trick for you on the

I'm trying to use Java's HttpURLConnection to do a “conditional get”, but I never get a 304 status code

六眼飞鱼酱① 提交于 2019-12-03 18:00:08
问题 Here is my code: final HttpURLConnection conn = (HttpURLConnection) sourceURL.openConnection(); if (cachedPage != null) { if (cachedPage.eTag != null) { conn.setRequestProperty("If-None-Match", cachedPage.eTag); } conn.setIfModifiedSince(cachedPage.pageLastModified); } conn.connect(); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { newCachedPage.eTag = conn.getHeaderField("ETag"); newCachedPage.pageLastModified = conn.getHeaderFieldDate("Last-Modified", 0); } else if (conn

Etags and last-modified over https SSL?

我是研究僧i 提交于 2019-12-03 17:36:57
问题 Is it possible to use HTTP caching for conditional GET requests over a secure HTTPS connection? I've got caching working over non-secure HTTP, but when I switch to HTTPS the browser stops sending if-none-match and if-modified-since headers, so the caching breaks. I've tried various Cache-Control settings like public, max-age=3600 and whatnot, no dice. This happens in both Safari and Chrome, so I'm assuming the SSL is breaking it somehow. Is caching not allowed over SSL? And just to be clear,

Azure CDN - Enabling HTTP 304 Caching with ETag - Hosted Web Role

折月煮酒 提交于 2019-12-03 14:55:23
We are trying to enable HTTP compression (gzip) and HTTP 304 Caching via ETags on Azure CDN. We already discovered an issue with enabling Azure CDN Compression , but now we can't get compression and ETag caching ( 304s ) working simultaneously. This issue has been posted to Azure forums here . Here is an example of the compressed , but not HTTP cacheable (304) link: https://xxxx.vo.msecnd.net/resourceManager.axd?token=HL80vX5hf3lIAAA&group=core.js Here is an example of the cacheable (304) , but not compressible (gzip) link: https://xxxx.vo.msecnd.net/resourceManager.axd?token=HL80vX5hf3lIAAA

HttpCache vs Singleton - Best practice for an MVC application

白昼怎懂夜的黑 提交于 2019-12-03 12:59:58
问题 I am little bit confused in understanding of the HttpCache and Singleton approaches. My application uses Asp.net MVC and the scenario is that, I have some List of Data that will never change and some data that might rarely change. I have developed and deployed application using a Singleton repository for this type of data. It performs great. The only issue is that when a rare case occur, i have to restart IIS to take effect. What is the best solution.? Singleton implementation public class

How do I set Expires: header when using send_data

老子叫甜甜 提交于 2019-12-03 12:20:59
I have a method in my controller which uses send_data like this: def show expires_in 10.hours, :public => true send_data my_image_generator, :filename => "image.gif", :type => "image/gif" end Using expires_in results in headers being sent like this: HTTP/1.1 200 OK Connection: close Date: Fri, 25 Jun 2010 10:41:22 GMT ETag: "885d75258e9306c46a5dbfe3de44e581" Content-Transfer-Encoding: binary X-Runtime: 143 Content-Type: image/gif Content-Disposition: inline; filename="image.gif" Content-Length: 1277 Cache-Control: max-age=36000, public What I would like to do is add an header like Expires:

HTTP Caching with Authorization

人盡茶涼 提交于 2019-12-03 12:04:31
Given a response from a web server that contains an Authorization header as per the OAuth spec does HTTP caching fail to be useful? Request1 Authorization : AUTHTOKEN Request2 Authorization : ANOTHERAUTOTOKEN In this case given HTTP caching the second request would return the cached response for the first user. This isn't a problem for content that is generic across users, but this feels wrong for a shared cache to be providing responses for other users. Likewise if we were to use a Vary header and vary by Authorization , this means our cache would store a cached copy per token which surely

HTTP: Combining expiration and validation caching

别来无恙 提交于 2019-12-03 07:54:38
问题 I'm having trouble formulating HTTP cache headers for the following situation. Our server has large data that changes perhaps a couple times a week. I want browsers to cache this data. Additionally, I want to minimize latency from conditional gets as the network is unreliable. The end behavior I'm after is this: Client requests a resource it hasn't seen before. Server responds with resource along with ETag and max-age (24 hours). Until 24 hours has passed, client will use cached resource.