is it possible to invalidate cache of a specific image using ImageResizer? - imageresizer

I am using ImageResizer (http://imageresizing.net/) and was curious if anyone has found a way to clear the cache for a particular item?
This would help me out greatly as I have some legacy systems that need to get updated images and I cannot add any query string parameters to the to images to refresh the cache.

In order to scale to millions of items, DiskCache does not maintain a cross-reference table between source files and cached images - it instead uses a one-way hash function that combines the source file, modified date, and commands.
If you want to do invalidation, your provider needs to support it via IVirtualFileWithModifiedDate. There is a cost associated with invalidation checks on every request, so some form of windowed caching is suggested.
You can also use URL rewriting to map "legacy URLs" to new immutable urls. For small numbers of images, this is the most performant approach. Keep in mind that even if ImageResizer is serving the right image, there are other layers of caching (browser, proxy, etc) that will get in the way.

Related

Flushing S3 DiskCache for single image

I am testing DiskCache with S3Reader2 for an imagecollection and it caches very nice and seemless.
However I have a hard time finding any info on clearing the diskcache for an image - which I need after image-update.
Is that possible via querystring? Or via C# Code?
Thanks
S3Reader2 supports invalidation in V4+ with a sliding expiration window.
You can also take the easy approach and append "&cachebreaker=x" when your underlying file changes. This has the benefit of working immediately and across CDNs.

coldfusion MSFT SQL Image Store

I am using ColdFusion 10 and working on new project where the user will be allowed to upload pictures from events. Never worked with user uploaded images before. How do I store the image in MSFT SQL? Is there a best practice when it comes to users uploading huge 10 MEG pictures? Is there a way to control or automatically compress pictures?
Thanks!
This is a two part question:
Part 1:
First part will be your data store and pull. Where you will use in your cfquery, cfqueryparam that will look like this:
INSERT into EMPLOYEES (FirstName,LastName,Photo)
VALUES ('Aiden','Quinn',<cfqueryparam value="#ImageGetBlob(myImage)#" cfsqltype='cf_sql_blob'>)
To select then reconstruct you will use this:
<cfset myImage = ImageNew(#GetBLOBs.PHOTO#)>
Where you can then do this:
<img src='#myImage#>
Above examples pulled from the docs.
Get familiar with <cfimage> and cfscript version image() for editing (rotating, scaling, etc.)
Part 2:
The other part to your question has to do with upload limits.
Coldfuion has limits that can be changed in CFIDE or RAILO equivalent. There is also limiters set in your web service like apache and IIS, you will have to look into this to change it.
BUT if you are only concerned about 10 mb size images you will be fine. It is when you get into hundreds of MB size files that will cause you headaches.
Remember on your form to set your form enctype to this because you will have to upload your file to your server before you can work with it:
<form action="workPage.cfm" method="post" enctype="multipart/form-data">
Also you will have to access that file using <cffile>
I think all this is enough to get you started.
If you are concerned about the storage size of an image, and this is of course a reasonable concern, then you could use to scale the image down to the maximum dimensions and quality or compression level (if stored as a jpeg) that you need within your application.
Storing your images within a database allows them to be more easily portable, across a cluster for instance. If that is not a concern, then what I tend to do is generate a unique name for each image uploaded, rename them, and store the unique name in the database rather than the image itself.

Download large amount of images with objective-C

I'm currently developing an order entry application for my company. This means I need to download approximately 1900 product images to the iPad, and that's just the normal images. I also need to download an equal amount of thumbnails. The reason for downloading the images to the iPad instead of just displaying them from a given URL is that our reps wander into large stores which often don't have stable internet connections.
What would be the best course of action? The images are stored on our servers, but you need to be authenticated using Basic Auth before you can access those. I have thought of just downloading them one-by-one, which is tedious, or group them together on the server as a zip-file but that would be a large file.
A one-by-one is a valid options for the download. I have done projects with similar specs, so what I advise:
Use some 3rd party library to help you with the download of the images. MKNetworkKit for example. If you feel confortable enough, NSURLConnection is more than enough.
Store the images in the application sandbox.
Instead of downloading the thumbs, just create them on the go when you need them (Lazy pattern). Unless your image's thumbs are somewhat different than the original (some special effect).

Is there an automated way to push all my javascript/css/images to s3 everytime I do a website push?

So I am in the process of moving all the thumbnails of my major sites to S3 and now I am thinking about how I can consistently put all my CSS/JS/images that power the actual sites to it. It's easy enough to upload everything the first time but I am trying to think of a way to somehow automate the process everytime I push out to production.
Does anyone have any clever ways of doing this?
I used to use s3sync to compare and update the assets just before upload the site files using a bash file to iterate through my files
This works well but when the amount of likes to compare (lets say thousands) gets big this process start being really slow. If you have an small architecture (in term of assets) this would do the trick
to make this better I would recommend capistrano or some other assistant that helps you to deploy...this way you can run at all once..
upload assets
deploy your files
In the other hand you could take a look to cloudfront (amazon's CDN) and set it up using ORIGIN..this way you dont need to worry about upload the files to s3 since they will be automatically pulled on demand. The down side of this approach is the caching if you need to update a file and keep the same name (AKA expire the object)...you can do this in cloudfront but will need an script to do the task.
Depending in the traffic (and other factors, ofcourse) one or other path will fit the best.

iPad - how should I distribute offline web content for use by a UIWebView in application?

I'm building an application that needs to download web content for offline viewing on an iPad. At present I'm loading some web content from the web for test purposes and displaying this with a UIWebView. Implementing that was simple enough. Now I need to make some modifications to support offline content. Eventually that offline content would be downloaded in user selectable bundles.
As I see it I have a number of options but I may have missed some:
Pack content in a ZIP (or other archive) file and unpack the content when it is downloaded to the iPad.
Put the content in a SQLite database. This seems to require some 3rd party libs like FMDB.
Use Core Data. From what I understand this supports a number of storage formats including SQLite.
Use the filesystem and download each required file individually. OK, not really a bundle but maybe this is the best option?
Considerations/Questions:
What are the storage limitations and performance limitations for each of these methods? And is there an overall storage limit per iPad app?
If I'm going to have the user navigate through the downloaded content, what option is easier to code up?
It would seem like spinning up a local web server would be one of the most efficient ways to handle the runtime aspects of displaying the content. Are there any open source examples of this which load from a bundle like options 1-3?
The other side of this is the content creation and it seems like zipping up the content (option 1) is the simplest from this angle. The other options would appear to require creation of tools to support the content creator.
If you have the control over the content, I'd recommend a mix of both the first and the third option. If the content is created by you (like levels, etc) then simply store it on the server, download a zip and store it locally. Use CoreData to store an Index about the things you've downloaded, like the path of the folder it's stored in and it's name/origin/etc, but not the raw data. Databases are not thought to hold massive amounts of raw content, rather to hold structured data. And even if they can -- I'd not do so.
For your considerations:
Disk space is the only limit I know on the iPad. However, databases tend to get slower if they grow too large. If you barely scan though the data, use the file system directly -- may prove faster and cheaper.
The index in CoreData could store all relevant data. You will have very easy and very quick access. Opening a content will load it from the file system, which is quick, cheap and doesn't strain the index.
Why would you do so? Redirect your WebView to a file:// URL will have the same effect, won't it?
Should be answered by now.
If you don't have control then use the same as above but download each file separately, as suggested in option four. after unzipping both cases are basically the same.
Please get back if you have questions.
You could create a xml file for each bundle, containing the path to each file in the bundle, place it in a folder common to each bundle. When downloading, download and parse the xml first and download each ressource one by one. This will spare you the overhead of zipping and unzipping the content. Create a folder for each bundle locally and recreate the folder structure of the bundle there. This way the content will work online and offline without changes.
With a little effort, you could even keep track of file versions by including version numbers in the xml file for each ressource, so if your content has been partially updated only the files with changed version numbers have to be downloaded again.