I understand what you're saying, but really you don't have it understand it, you can just copy the code. It seems easier than figuring out how to set the bits yourself.
BTW, I'm not sure 100% sure, but I think your problem was not caching but the fact that you need to set that bit in the options field.