Thanks to everyone who attended my session on ASP.NET scalability at WebDD today - I hope you all found it useful. I got to the end of the section on caching, which is more or less the first half, and realised I had ten minutes left for the entire second half, so apologies for having to race through the rest of the slides. If anyone has any questions please feel free to post them in the comments here and I'll answer them.
I had a few questions afterwards over coffee, which were:
Q) Output Caching. Can you VaryBy things other than elements in the QueryString?
A) Yes, there are a range of VaryBy options: VaryByContentEncoding, VaryByControl, VaryByHeader, and VaryByCustom. In each case ultimately it boils down to a string. There's a discussion of all these options on MSDN, but basically VaryByContentEncoding's probably not going to help you too much since this looks at what encodings your browser can accept e.g. compressed content (and remember that I mentioned all the current browsers (and previous generation browsers) can accept compressed content). VaryByHeader looks at a semi-colon seperated list of HTTP headers. VaryByControl looks at the controls declared inside a UserControl. VaryByCustom is perhaps the most interesting as it allows you to roll your own scheme by implementing GetVaryByCustomString in your Global.asax file, or if you set it to 'browser' it caches page instances based on the browser name and major version.
Q) Is there a reason not to use VaryByParam=*?
A) VaryByParam=* will cache pages on all combinations of elements in the QueryString - I can only tell you what it does, it's up to you to decide whether this facility is going to fit into your application or not.
Q) Can you cache objects for longer than 20 minutes?
A) Yes. If you use sliding expiration, it takes a System.TimeSpan object. TimeSpan has three constructors - I used the hours/minutes/seconds constructor, but there's nothing to stop you using the second constructor which adds a days parameter onto the constructor. Bear in mind, however, that doing that means you're sacrificing that much memory on your server for that length of time. As with so many things in scalability, it's a trade-off...
Q) Do you need command-line access to your server to enable a SQL database for SQLCacheDependencies?
A) No. There's two options here: one is to keep in mind that the ASPNET_REGSQL command-line tool takes a server name from the -S parameter - this can be any SQL server that is on your network, you don't have to run the tool locally to the server you're enabling.
The second option is to use the SqlCacheDependencyAdmin static class, which gives you the ability to programmatically enable and disable databases and tables for cache dependencies.
Showing posts with label compression. Show all posts
Showing posts with label compression. Show all posts
Saturday, 18 April 2009
Thursday, 4 December 2008
SQLExpress and Compressed Files
Another of those things I'm blogging for future reference...
A little while ago I ran the Windows Disk Cleanup utility to recover some space on my hard drive. One of the things it did was go through my filesystem and compress files that I hadn't used in a little while.
I went back to some of those files yesterday - a WinForms project that I started ages ago that uses a SQL Express database - but when I tried to run the project I got strange errors in my DAL. I fired up SQL Management Studio and attached to my SQL Express instance, where things got even stranger. I had two databases showing, one with the path to my database and one with just the name of the database, but no plus sign next to them to expand them. Couldn't detach them, couldn't delete them. I did a bit of Googling and I saw a comment that SQL Express doesn't work with compressed files. Almost instantly I figured out what had happened - I uncompressed all the files in the folder and everything started behaving itself again.
A little while ago I ran the Windows Disk Cleanup utility to recover some space on my hard drive. One of the things it did was go through my filesystem and compress files that I hadn't used in a little while.
I went back to some of those files yesterday - a WinForms project that I started ages ago that uses a SQL Express database - but when I tried to run the project I got strange errors in my DAL. I fired up SQL Management Studio and attached to my SQL Express instance, where things got even stranger. I had two databases showing, one with the path to my database and one with just the name of the database, but no plus sign next to them to expand them. Couldn't detach them, couldn't delete them. I did a bit of Googling and I saw a comment that SQL Express doesn't work with compressed files. Almost instantly I figured out what had happened - I uncompressed all the files in the folder and everything started behaving itself again.
Subscribe to:
Posts (Atom)