caching

Cache home page for non-authenticated users in ASP.NET MVC 3

醉酒当歌 提交于 2020-01-03 16:04:21
问题 My website have a home page, and I would like to cache that page for anonymous users, and set it as "private" for authenticated users (so they save it on their computers, nowhere else). So, if the user is anonymous I want to save the page in the server cache, and also in the browser cache using Cache-control:public, max-age=60 and Vary:Cookie , so if the browser gets authenticated and send a cookie, the browser won't reuse the former stored page. If the user is authenticated, then I do not

Spring Caching - ignore parameter for key

↘锁芯ラ 提交于 2020-01-03 15:56:12
问题 I want to cache the results of a simple getter that has an optional parameter (user-agent in the example below). How can I instruct the key to be created without taking into consideration the optional user-agent parameter? @Cacheable(value="bookCache") public Book getBooks(@RequestHeader(value = "user-agent", required = false) String userAgent) ... 回答1: One could customize how a key for a certain cache-object is created by providing a custom KeyGenerator. Here's what it could look: @Service

How to implement synchronized Memcached with database

六月ゝ 毕业季﹏ 提交于 2020-01-03 13:36:26
问题 AFAIK, Memcached does not support synchronization with database (at least SQL Server and Oracle). We are planning to use Memcached (it is free) with our OLTP database. In some business processes we do some heavy validations which requires lot of data from database, we can not keep static copy of these data as we don't know whether the data has been modified so we fetch the data every time which slows the process down. One possible solution could be Write triggers on database to create/update

HTML cache history back

依然范特西╮ 提交于 2020-01-03 12:30:10
问题 If I use history.back() for button press then what will happen? Will the HTML content be displayed from the local history of the browser or the cache and without the browser requesting to the server? Or will the browser request to the server based on the URL that resides in history of browser? 回答1: Calling "history.back()" in JavaScript is the same as hitting the back button in the browser's user interface (however, there can be slight differences if the currently viewed location contains

Load External Script and Style Files in a SPA

蓝咒 提交于 2020-01-03 10:09:07
问题 I have a type of SPA which consumes an API in order to fetch data. There are some instance of this SPA and all of them use common style and script files. So my problem is when I change a single line in those files, I will have to open each and every instances and update the files. It's really time consuming for me. One of the approaches is to put those files in a folder in the server, then change the version based on the time, but I will lose browser cache if I use this solution: <link href=

CSS file name case sensitivity & Css file caching

纵饮孤独 提交于 2020-01-03 08:53:41
问题 We are in the process of rewriting some of our websites and trying to make the most use of browser caching for our users. We have created a group of shared css files that we plan to use as a "corporate branding" across multiple sites that we've created. The reason for this, we know that browsers will cache a CSS file for a determined length of time. What if I specify the same file name in different sites with a different casing, will it cache both version of the file (even tho they are the

CSS file name case sensitivity & Css file caching

泄露秘密 提交于 2020-01-03 08:53:01
问题 We are in the process of rewriting some of our websites and trying to make the most use of browser caching for our users. We have created a group of shared css files that we plan to use as a "corporate branding" across multiple sites that we've created. The reason for this, we know that browsers will cache a CSS file for a determined length of time. What if I specify the same file name in different sites with a different casing, will it cache both version of the file (even tho they are the

How to configure NginX to serve Cached Content only when Backend is down (5xx Resp. Codes)?

牧云@^-^@ 提交于 2020-01-03 08:45:12
问题 I've configured my system with NginX listening on port 80, serving static content and proxying dynamic requests to a backend server. I can configure NginX to cache content generated by the backend, but I want this cached content be served only when the Backend responds with an error http 5xx , or when it's totally down. We tried the proxy_cache_use_stale option with max-age of 1 second, it worked but it has one negative side.. which is simply dozens of requests being served from cache during

Chrome slow to load resources `(from disk cache)`

假如想象 提交于 2020-01-03 08:37:13
问题 My site http://www.front-end.io configures the HTTP requests to load resources from cache with first priority. So my header will be like: cache-control:max-age=315360000 ETag:W/"11913b-ks0rwRQM+ijHcl1HDuse3g" Chrome indeed does not initiate any request (even 304) to the server, it loads from the cache directly: It takes my Windows10 Chrome >400ms to load the js file from local disk. My Ubuntu Chromium also takes >100ms. But FireFox takes around 10ms only! I found this question as well, Google

Delete a header in PHP

独自空忆成欢 提交于 2020-01-03 08:31:10
问题 To allow caching a PHP generated file, I want to make sure, that the 'Pragma: no-cache' header is not set. However, how do I delete a possibly already set header? That is, it could be possible, that somewhere in the code someone wrote header('Pragma: no-cache'); and now I want to make sure, the header is not sent. Is it sufficient to do this: header('Pragma:'); or is there something like delete_header() (which would, apparently, be undocumented or well-hidden)? 回答1: header_remove() since php