add local cache support, some bug fixed