OpenLayers - is (local) caching possible beyond the LocalStorage? - openlayers-3

There is a (standard) caching feature for OpenLayers via LocalStorage. The size of LocalStorage is per app max 10Mb.
Is there a (standard or) easy way to cache tiles locally on the mobile so they can be used for offline presentation / navigation? In this way the caching could exceed the 10MB limit.
If so, what are the disadvantages?

Caching map requests are possible in a number of ways. As a first introduction, I refer to a recommendation for storing data offline:
Progressive web apps: for URL addressable resources, use the Cache API (part of Service Worker).
For all other data, use IndexedDB (with a Promises wrapper).

Related

Asp.Net Core Web App Play and download Video from Disk

I am having a scenario here. I have to build an asp.net core web application from where I have to browse drive and directories (where hosted: windows) and list the available video files. This portion working perfectly.
Now I have to do two things with those video files:
Need to download files (working except the size is < 2 GB)
Need to play the video on the page whatever the format and size is.
Asking for your helps. Thanks in advance.
If your website videos, each video is very small, assuming that the video size in a single page does not exceed 100M, or your internet speed is extremely fast, I think your needs are feasible.
What I said above is only the content contained in a single page. When there are not many video resources, the page loading speed is related to the bandwidth.
It is very simple to read files under a certain path, but I think the network speed and the performance of IIS are the bottleneck for reading and downloading.
Reason and suggestions
1. IIS web server just host web application, and also can store some small static resources, such as website pictures, css and js files.
IIS itself is on windows. When there are not many users, it can run normally by accessing 1G video. It can be loaded slowly. But what if there are many users, such as 100 people or 1000+ people visiting at the same time? I think the pressure on the web server is very high, so your idea is only suitable for a small range of users, and it is recommended that the video resources should not be too large.
2. I suggest you use third-party media services to store and read videos. For example, use Azure Media Service.
The reason is that if the video resource under the path is read through the web server, it must be very slow in terms of video loading, especially when the file is large and more users access it, the phenomenon will be particularly obvious.
Using Azure Media Services, the opening speed and download speed of playing videos will be improved. As a web server, IIS will no longer bear the pressure of this part of the media service.

What is the best way to Cache JSON request images for offline use?

I am new to networking and data caching in general. I am making a network request that returns me url strings which lead to images. I want to cache this data for offline use. What is the smartest way to do this using Apples frameworks(no third party libraries)?
Thank you!
If you do not want to use third-party libs you have only two options: write your own solution or use a NSURLCache
NSURLCache allows you to cache downloaded data in memory and on disk. The only issue with NSURLCache is that it does not guaranties everything you downloaded will be saved. For example it does not save (at least in iOS8) files that are bigger than 5% of the maximum disk usage. Also cache storage could be erased if device is out of the disk space. So NSURLCache usually is not suitable if you need a fully working offline solution. But it works great if you just need to reduce a network usage.
You could also read about NSURLCache here

ImageResizer .net for multiple product images perfomance issues?

I'm building an Asp.Net MVC4 Application with product pages. I have come by the ImageResizer Library for handling and serving the images. My page has jpg thumbnails 160x160px in dimensions and 3~5KB size each.
To my understanding using the ImageResizer library i could just upload the original large product image 600 x 600px & 10~20KB and resize it on the fly to the thumbnail size when the visitor requests the page. Something like:
<img src="#Url.Content("~/images/imagename?width=160&height=160")" alt="">
Which i understand is fine for a couple of images but my product page consists of 20 to 100 product jpg unique thumbnails (depending on pagesize).
Should performance hurt with processing on-the-fly 20-100 pics each time? Has anyone faced a similar scenario? I could always go back back and generate 2 different images (thumbnail and large) during the upload process but i'm very curius if i could get away with just one image per product and dynamic resizing.
When i say performance i mean that anything above 0.5 - 1s extra response time is a no-no for me.
In documentation it is mentioned, that there's caching plugin, which improves performance by 100-10000X:
Every public-facing website needs disk caching for their dynamically resized images (no, ASP.NET's output cache won't work). This module is extremely fast, but decoding the original image requires a large amount of contiguous RAM (usually 50-100MB) to be available. Since it requires contiguous, non-paged, non-fragmented RAM, it can't be used a (D)DOS attack vector, but it does mean that there is a RAM-based limit on how many concurrent image processing requests can be handled. The DiskCache plugin improves the throughput 100-10,000X by delegating the serving of the cached files back to IIS and by utilizing a hash-tree disk structure. It easily scales to 100,000 variants and can be used with as many as a million images. It is part of the Performance edition, which costs $249. The DiskCache plugin requires you to use the URL API (read why).
http://imageresizing.net/plugins/diskcache
http://imageresizing.net/docs/basics
When it comes to websites, every operation that can be cached should be. This allows the server to deal with more visitors rather than more processing.
You could either use the caching plugin for ImageResizer, or manually write to file using a certain filename, e.g.: product_154_180x180.jpg where 154 is product id, and 180 is the width and height, then check for whether it exists when you want to display it.
If you do the latter, you may be able to use the server to manage this for you, by linking to the expected filename in the page source, and if it doesn't exist, the server then calls a script that resizes and writes the resized image to disk using imageresizer.
This last method will also avoid the call to ImageResizer saving you some processing power.

Out of memory .NETCF Windows Mobile 5

We have a .NETCF 3.5 app written in C# where we use some fairly large lists and dictionaries of objects, populated with data from a SQL Server and persisted to SQLCE databases on the device.
The app was running very well until recently. The amount of data is such that we are getting Out of memory exceptions quite frequently. Using the Hibernate event, I have confirmed that the OS is indeed asking the app to free up resources (the Hibernate event gets fired constantly). The rub is that I really do not see anything substantial that I can free up - the lists and dictionaries, etc. are all being used by the application.
I know there is a hard 32 MB / app limit in Mobile 5/6 (in reality only 18-20 MB, per http://dev.fittingsites.com/bol/2008/windows-mobile-6-1-memory-management-changes).
I am a bit at a loss here. If the app needs about 25 MB to operate, how can it run on Mobile 5? Are there workarounds, like storing lists or dictionaries in Memory Mapped Files or similar that would not require a ton of work (or slow things down much)?
Which method are you using to read data from your SQLCE database? SQLCE provides two main approaches: DataSets and ResultSets. DataSets are known to consume huge amounts of memory and to reduce the application performance. If you are using DataSets I would recommend trying to switch your application to use RecordSets instead. See this page for more details.

Generate thumbnail images at run-time when requested, or pre-generate thumbnail in harddisk?

I was wondering, which way of managing thumbnail images make less impact to web server performance.
This is the scenario:
1) each order can have maximum of 10 images.
2) images does not need to store after order has completed (max period is 2 weeks).
3) potentially, there may have a few thousands of active orders at anytime.
4) orders with images will frequently visit by customers.
IMO, pre-generate thumbnail in hard disk is a better solution as hard disk are cheaper even with RAID.
But what about disk I/O speed, and resource it need to load images? will it take more resource than generate thumbnails at real-time?
It would be most appreciate if you could share your opinion.
I suggest a combination of both - dynamic generation with disk caching. This prevents wasted space from unused images, yet adds absolutely no overhead for repeatedly requested images. SQL and mem caching are not good choices, both require too much RAM. IIS can serve large images from disk while only using 100k of RAM.
While creating http://imageresizing.net, I discovered 29 image resizing pitfalls, and few of them are obvious. I strongly suggest reading the list, even if it's a bit boring. You'll need an HttpModule to be able to pass cached requests off to IIS.
Although - why re-invent the wheel? The ImageResizer library is widely used and well tested.
If the orders are visited frequently by customers, it is better to create the thumbnails ones and store on disk. this way the webserver doesn't need to process the page that long. It will speed up the loading time of your webpages.
It depends on your load. If the resource is being requested multiple times then it makes sense to cache it.
Will there always have to be an image? If not, you can create it on the first request and then cache it either in memory, or more likely a database, for subsequent requests.
However, if you always need the n images to exists per order, and/or you have multiple orders being created regularly, you will be better off passing the thumbnail creation off to a worker thread or some kind of asynchronous page. That way, multiple request's can be stacked up, reducing load on the server.

Resources