Fix caching issues of cython magic.

Should fix https://github.com/ipython/ipython/issues/6507 when using cython magic. 
We will deprecate cython magic in IPython itself.