I would go with a combo of Dipak and Toni's answers. I think the happy medium lies between. What should happen here is wholly dependent on what your users would expect to happen. This is where user testing comes in. There is really no substitute for knowing who your users are: what they think, how they feel, how they work, etc.
That said, there's still obviously generalizations that can be made for any user. First, recognize that there's a clear difference between creating something and editing something. If I'm creating some new thing, then I want my work saved at all costs. There's no going back, and the barrier to entry is usually higher than with modifications. Here, you either prompt the user to confirm they want to cancel or as Toni implies, use local storage to save the entered data, so if they reopen the form, they're right back to where they left off. With the latter, it's not necessary to prompt the user, but it can help to reduce temporary anxiety should they accidentally cancel and don't realize that you're silently saving their work.
With editing, it's a little different. Here, as a user I expect canceling to revert. In other words, it no longer makes sense to save the users changes to local storage and persist them after canceling. If I change something irreparably and want to go back to the old version, canceling is my escape hatch. You should definitely, now, prompt the user to confirm, so that an accidental click doesn't undo their work.